diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
index 946645d..060e793 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
@@ -191,6 +191,10 @@ public function getValue() {
     if ($this->hasNewEntity()) {
       $values['entity'] = $this->entity;
     }
+    // The NEW_ENTITY_MARKER is an implementation detail, don't return that.
+    if ($this->target_id === static::$NEW_ENTITY_MARKER) {
+      unset($values['target_id']);
+    }
     return $values;
   }
 
diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php
index 0898f48..4baf594 100644
--- a/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php
+++ b/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php
@@ -208,6 +208,10 @@ public function testEntitySaveOrder() {
     $entity->name->value = $this->randomMachineName();
     // Now save the term.
     $term->save();
+    // Now get the field value.
+    $value = $entity->get('field_test_taxonomy_term');
+    // And then set it.
+    $entity->field_test_taxonomy_term = $value;
     // And then the entity.
     $entity->save();
     $this->assertEqual($entity->field_test_taxonomy_term->entity->id(), $term->id());
