diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php
index c51b278ad091c9220b605072f7991af1bdd67bb1..440ce8ea281b5e10f32b9ae800456ac2c8dc02c8 100644
--- a/core/modules/migrate/src/MigrateExecutable.php
+++ b/core/modules/migrate/src/MigrateExecutable.php
@@ -229,7 +229,9 @@ public function import() {
         $save = FALSE;
       }
       catch (MigrateSkipRowException $e) {
-        $id_map->saveIdMapping($row, array(), MigrateIdMapInterface::STATUS_IGNORED);
+        if ($e->getSaveToMap()) {
+          $id_map->saveIdMapping($row, [], MigrateIdMapInterface::STATUS_IGNORED);
+        }
         $save = FALSE;
       }
 
diff --git a/core/modules/migrate/tests/modules/migrate_prepare_row_test/src/Plugin/migrate/process/TestSkipRowProcess.php b/core/modules/migrate/tests/modules/migrate_prepare_row_test/src/Plugin/migrate/process/TestSkipRowProcess.php
new file mode 100644
index 0000000000000000000000000000000000000000..4822113b325459e0dd04188328c83ee64f157c30
--- /dev/null
+++ b/core/modules/migrate/tests/modules/migrate_prepare_row_test/src/Plugin/migrate/process/TestSkipRowProcess.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Drupal\migrate_prepare_row_test\Plugin\migrate\process;
+
+use Drupal\migrate\MigrateExecutableInterface;
+use Drupal\migrate\MigrateSkipRowException;
+use Drupal\migrate\ProcessPluginBase;
+use Drupal\migrate\Row;
+
+/**
+ * Provides a testing process plugin that skips rows.
+ *
+ * @MigrateProcessPlugin(
+ *   id = "test_skip_row_process"
+ * )
+ */
+class TestSkipRowProcess extends ProcessPluginBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
+    // Test both options for save_to_map.
+    $data = $row->getSourceProperty('data');
+    if ($data == 'skip_and_record (use plugin)') {
+      throw new MigrateSkipRowException('', TRUE);
+    }
+    elseif ($data == 'skip_and_dont_record (use plugin)') {
+      throw new MigrateSkipRowException('', FALSE);
+    }
+    return $value;
+  }
+
+}
diff --git a/core/modules/migrate/tests/src/Kernel/MigrateSkipRowTest.php b/core/modules/migrate/tests/src/Kernel/MigrateSkipRowTest.php
index acad26d25a35509d82f57f524fceb95b92d94510..44df50178ed61b88c7214f4fe15bb54ed76d4a08 100644
--- a/core/modules/migrate/tests/src/Kernel/MigrateSkipRowTest.php
+++ b/core/modules/migrate/tests/src/Kernel/MigrateSkipRowTest.php
@@ -62,6 +62,30 @@ public function testPrepareRowSkip() {
     $map_row = $id_map_plugin->getRowBySource(['id' => 2]);
     $this->assertFalse($map_row);
 
+    // Insert a custom processor in the process flow.
+    $definition['process']['value'] = [
+      'source' => 'data',
+      'plugin' => 'test_skip_row_process',
+    ];
+    // Change data to avoid triggering again hook_migrate_prepare_row().
+    $definition['source']['data_rows'] = [
+      ['id' => '1', 'data' => 'skip_and_record (use plugin)'],
+      ['id' => '2', 'data' => 'skip_and_dont_record (use plugin)'],
+    ];
+    $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
+
+    $executable = new MigrateExecutable($migration, new MigrateMessage());
+    $result = $executable->import();
+    $this->assertEquals($result, MigrationInterface::RESULT_COMPLETED);
+
+    $id_map_plugin = $migration->getIdMap();
+
+    // The first row is recorded in the map as ignored.
+    $map_row = $id_map_plugin->getRowBySource(['id' => 1]);
+    $this->assertEquals(MigrateIdMapInterface::STATUS_IGNORED, $map_row['source_row_status']);
+    // The second row is not recorded in the map.
+    $map_row = $id_map_plugin->getRowBySource(['id' => 2]);
+    $this->assertFalse($map_row);
   }
 
 }