diff --git a/plugins/FeedsUserProcessor.inc b/plugins/FeedsUserProcessor.inc
index 25ce1e6..94e70e2 100644
--- a/plugins/FeedsUserProcessor.inc
+++ b/plugins/FeedsUserProcessor.inc
@@ -65,6 +65,7 @@ class FeedsUserProcessor extends FeedsProcessor {
     $account->uid = 0;
     $account->roles = array_filter($this->config['roles']);
     $account->status = $this->config['status'];
+    $account->is_new = TRUE;
 
     return $account;
   }
@@ -104,6 +105,21 @@ class FeedsUserProcessor extends FeedsProcessor {
     if (empty($account->name) || empty($account->mail) || !valid_email_address($account->mail)) {
       throw new FeedsValidationException(t('User name missing or email not valid.'));
     }
+
+    // Check when an user ID gets set or changed during processing if that user
+    // ID is not already in use.
+    if (!empty($account->uid)) {
+      $is_new = !empty($account->feeds_item->is_new);
+      $different = !empty($account->feeds_item->entity_id) && $account->feeds_item->entity_id != $account->uid;
+      if ($is_new || $different) {
+        $exists = entity_load_unchanged('user', $account->uid);
+        if ($exists) {
+          throw new FeedsValidationException(t('Could not update user ID to @uid since that ID is already in use.', array(
+            '@uid' => $account->uid,
+          )));
+        }
+      }
+    }
   }
 
   /**
@@ -121,6 +137,17 @@ class FeedsUserProcessor extends FeedsProcessor {
       unset($edit['pass']);
     }
 
+    // Check if the user ID changed when updating users.
+    if (!empty($account->feeds_item->entity_id) && $account->feeds_item->entity_id != $account->uid) {
+      // The user ID of the existing user is different. Try to update the user ID.
+      db_update('users')
+        ->fields(array(
+          'uid' => $account->uid,
+        ))
+        ->condition('uid', $account->feeds_item->entity_id)
+        ->execute();
+    }
+
     user_save($account, $edit);
 
     // If an encrypted password was given, directly set this in the database.
@@ -249,6 +276,11 @@ class FeedsUserProcessor extends FeedsProcessor {
   public function getMappingTargets() {
     $targets = parent::getMappingTargets();
     $targets += array(
+      'uid' => array(
+        'name' => t('User ID'),
+        'description' => t('The uid of the user. NOTE: use this feature with care, user ids are usually assigned by Drupal.'),
+        'optional_unique' => TRUE,
+      ),
       'name' => array(
         'name' => t('User name'),
         'description' => t('Name of the user.'),
@@ -309,6 +341,10 @@ class FeedsUserProcessor extends FeedsProcessor {
     // target's value.
     foreach ($this->uniqueTargets($source, $result) as $target => $value) {
       switch ($target) {
+        case 'uid':
+          $uid = db_query("SELECT uid FROM {users} WHERE uid = :uid", array(':uid' => $value))->fetchField();
+          break;
+
         case 'name':
           $uid = db_query("SELECT uid FROM {users} WHERE name = :name", array(':name' => $value))->fetchField();
           break;
diff --git a/tests/feeds/users.csv b/tests/feeds/users.csv
index eb13a19..bdd01bd 100644
--- a/tests/feeds/users.csv
+++ b/tests/feeds/users.csv
@@ -1,6 +1,6 @@
-name,mail,since,password,password_md5,password_sha512
-Morticia,morticia@example.com,1244347500,mort,e0108a7eb91670308fff8179a4785453,$S$DfuNE4ur7Jq8xVoJURGm8oMIYunKd366KQUE6akc3EXW/ym9ghpq
-Fester,fester@example.com,1241865600,fest,c8cce3815094f01f0ab774fd4f7a77d4,$S$DjJPqmjlWTIen0nQrG3a.vA71Vc0DqCpKuB.g9zmBMnGzIV6JxqH
-Gomez,gomez@example.com,1228572000,gome,8a5346b9a510f1f698ab0062b71201ac,$S$Dv.EtHlTfnrxuWGLbe3cf31mD9MF6.4u2Z46M2o2dMGgQGzi7m/5
-Wednesday,wednesdayexample.com,1228347137,wedn,fefb673afaf531dbd78771976a150dc8,$S$DdPzksGh/c8UukipWagAhTzaqUp/eNHVPiC.x6URBQyA503Z41PI
-Pugsley,pugsley@example,1228260225,pugs,09189568a8ee4d0addf53d2f6e4847cd,$S$D1oUihjrYXr.4iesN8Sfw1rVRLdo188v0NRGgcNR/V09oIyYPYmZ
+uid,name,mail,since,password,password_md5,password_sha512
+201,Morticia,morticia@example.com,1244347500,mort,e0108a7eb91670308fff8179a4785453,$S$DfuNE4ur7Jq8xVoJURGm8oMIYunKd366KQUE6akc3EXW/ym9ghpq
+202,Fester,fester@example.com,1241865600,fest,c8cce3815094f01f0ab774fd4f7a77d4,$S$DjJPqmjlWTIen0nQrG3a.vA71Vc0DqCpKuB.g9zmBMnGzIV6JxqH
+203,Gomez,gomez@example.com,1228572000,gome,8a5346b9a510f1f698ab0062b71201ac,$S$Dv.EtHlTfnrxuWGLbe3cf31mD9MF6.4u2Z46M2o2dMGgQGzi7m/5
+204,Wednesday,wednesdayexample.com,1228347137,wedn,fefb673afaf531dbd78771976a150dc8,$S$DdPzksGh/c8UukipWagAhTzaqUp/eNHVPiC.x6URBQyA503Z41PI
+205,Pugsley,pugsley@example,1228260225,pugs,09189568a8ee4d0addf53d2f6e4847cd,$S$D1oUihjrYXr.4iesN8Sfw1rVRLdo188v0NRGgcNR/V09oIyYPYmZ
diff --git a/tests/feeds_processor_user.test b/tests/feeds_processor_user.test
index 2608bde..f4a6e42 100644
--- a/tests/feeds_processor_user.test
+++ b/tests/feeds_processor_user.test
@@ -142,6 +142,124 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase {
   }
 
   /**
+   * Tests mapping to user ID.
+   */
+  public function testUidTarget() {
+    // Set to update existing users.
+    $this->setSettings('user_import', 'FeedsUserProcessor', array('update_existing' => FEEDS_UPDATE_EXISTING));
+
+    // Add mapping to user ID.
+    $this->addMappings('user_import', array(
+      4 => array(
+        'source' => 'uid',
+        'target' => 'uid',
+        'unique' => TRUE,
+      ),
+    ));
+
+    // Create account with uid 202. The username and mail address of this account
+    // should be updated.
+    user_save(drupal_anonymous_user(), array(
+      'uid' => 202,
+      'name' => 'Joe',
+      'mail' => 'joe@example.com',
+      'pass' => 'joe',
+      'status' => 1,
+    ));
+
+    // Import CSV file.
+    $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users.csv');
+    $this->assertText('Created 2 users');
+    $this->assertText('Updated 1 user');
+
+    // Assert user ID's.
+    $account = user_load_by_name('Morticia');
+    $this->assertEqual(201, $account->uid, 'Morticia got user ID 201.');
+    $account = user_load_by_name('Gomez');
+    $this->assertEqual(203, $account->uid, 'Gomez got user ID 203.');
+
+    // Assert that the username and mail address of account 202 were changed.
+    $account = user_load(202);
+    $values = array(
+      'name' => array(
+        'expected' => 'Fester',
+        'actual' => $account->name,
+      ),
+      'mail' => array(
+        'expected' => 'fester@example.com',
+        'actual' => $account->mail,
+      ),
+    );
+    $this->assertEqual($values['name']['expected'], $values['name']['actual'], format_string('Username of account 202 changed in @expected (actual: @actual).', array(
+      '@expected' => $values['name']['expected'],
+      '@actual' => $values['name']['actual'],
+    )));
+    $this->assertEqual($values['mail']['expected'], $values['mail']['actual'], format_string('Mail address of account 202 changed in @expected (actual: @actual).', array(
+      '@expected' => $values['mail']['expected'],
+      '@actual' => $values['mail']['actual'],
+    )));
+
+    // Assert that user Joe no longer exists in the system.
+    $this->assertFalse(user_load_by_name('Joe'), 'No user with username Joe exists.');
+    $this->assertFalse(user_load_by_mail('joe@example.com'), 'No user with mail address joe@example.com exists.');
+  }
+
+  /**
+   * Tests if user ID's can be changed using the user ID target.
+   *
+   * Also checks if a clear error is reported when trying to change the
+   * user ID to something that is already in use.
+   */
+  public function testUidUpdating() {
+    // Set to update existing users.
+    $this->setSettings('user_import', 'FeedsUserProcessor', array('update_existing' => FEEDS_UPDATE_EXISTING));
+
+    // Add mapping to user ID, but do not mark target as unique.
+    $this->addMappings('user_import', array(
+      4 => array(
+        'source' => 'uid',
+        'target' => 'uid',
+      ),
+    ));
+
+    // Create an account which user ID should be updated.
+    user_save(drupal_anonymous_user(), array(
+      'uid' => 54,
+      'name' => 'Morticia',
+      'mail' => 'morticia@example.com',
+      'pass' => 'mort',
+      'status' => 1,
+    ));
+
+    // Create account with uid 202. Importing an other account with uid 202
+    // should fail.
+    user_save(drupal_anonymous_user(), array(
+      'uid' => 202,
+      'name' => 'Joe',
+      'mail' => 'joe@example.com',
+      'pass' => 'joe',
+      'status' => 1,
+    ));
+
+    // Import CSV file.
+    $this->importFile('user_import', $this->absolutePath() . '/tests/feeds/users.csv');
+    $this->assertText('Created 1 user');
+    $this->assertText('Updated 1 user');
+    $this->assertText('Failed importing 3 users.');
+    $this->assertText('Could not update user ID to 202 since that ID is already in use.');
+
+    // Assert Morticia's user ID got updated.
+    $account = user_load_by_name('Morticia');
+    $this->assertEqual(201, $account->uid, 'Morticia now got user ID 201.');
+    // Assert that Fester failed to import.
+    $this->assertFalse(user_load_by_name('Fester'), 'The account for Fester was not imported.');
+    // Assert that user 202 did not change.
+    $account = user_load(202);
+    $this->assertEqual('Joe', $account->name, 'The user name of account 202 is still Joe.');
+    $this->assertEqual('joe@example.com', $account->mail, 'The mail address of account 202 is still joe@example.com.');
+  }
+
+  /**
    * Tests mapping to role without automatically creating new roles.
    */
   public function testRoleTargetWithoutRoleCreation() {
