diff --git a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
index e82ed81cc2..5365915027 100644
--- a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
+++ b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
@@ -127,6 +127,20 @@ class EntityAutocomplete extends Textfield {
     // Store the selection settings in the key/value store and pass a hashed key
     // in the route parameters.
     $selection_settings = isset($element['#selection_settings']) ? $element['#selection_settings'] : [];
+
+    $entity = isset($selection_settings['entity']) ? $selection_settings['entity'] : NULL;
+    if ($entity instanceof EntityInterface) {
+      // Don't serialise the entity, just pack the ID's.
+      $entity_info = [
+        'uuid' => $entity->uuid(),
+        'entity_type' => $entity->getEntityTypeId(),
+      ];
+      if (!$entity_info['uuid']) {
+        $entity_info['id'] = $entity->id();
+      }
+      $selection_settings['entity'] = $entity_info;
+    }
+
     $data = serialize($selection_settings) . $element['#target_type'] . $element['#selection_handler'];
     $selection_settings_key = Crypt::hmacBase64($data, Settings::getHashSalt());
 
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php
index 11f048e6f8..de317ab4d4 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php
@@ -88,7 +88,10 @@ class EntityReferenceAutocompleteWidget extends WidgetBase {
     $referenced_entities = $items->referencedEntities();
 
     // Append the match operation to the selection settings.
-    $selection_settings = $this->getFieldSetting('handler_settings') + ['match_operator' => $this->getSetting('match_operator')];
+    $selection_settings = $this->getFieldSetting('handler_settings') + [
+      'match_operator' => $this->getSetting('match_operator'),
+      'entity' => $entity,
+    ];
 
     $element += [
       '#type' => 'entity_autocomplete',
diff --git a/core/modules/system/src/Controller/EntityAutocompleteController.php b/core/modules/system/src/Controller/EntityAutocompleteController.php
index 974c2ded33..965b580994 100644
--- a/core/modules/system/src/Controller/EntityAutocompleteController.php
+++ b/core/modules/system/src/Controller/EntityAutocompleteController.php
@@ -7,6 +7,8 @@ use Drupal\Component\Utility\Tags;
 use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Controller\ControllerBase;
 use Drupal\Core\Entity\EntityAutocompleteMatcher;
+use Drupal\Core\Entity\EntityRepositoryInterface;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\KeyValueStore\KeyValueStoreInterface;
 use Drupal\Core\Site\Settings;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -100,10 +102,39 @@ class EntityAutocompleteController extends ControllerBase {
         throw new AccessDeniedHttpException();
       }
 
+      $entity_info = isset($selection_settings['entity']) ? $selection_settings['entity'] : NULL;
+      if (is_array($entity_info)) {
+        $selection_settings['entity'] = $this->loadEntityFromIds($entity_info);
+      }
+
       $matches = $this->matcher->getMatches($target_type, $selection_handler, $selection_settings, $typed_string);
     }
 
     return new JsonResponse($matches);
   }
 
+  /**
+   * Loads an entity from storage given entity ID's.
+   *
+   * @param array $entity_info
+   *   An array containing keys, where either uuid or ID is required:
+   *   - 'entity_type': Required. An entity type ID.
+   *   - 'uuid': Optional. An entity UUID.
+   *   - 'id': Optional. An entity ID.
+   *
+   * @return \Drupal\Core\Entity\EntityInterface|null
+   *   The entity loaded from provided ID's, or null if it does not exist.
+   */
+  protected function loadEntityFromIds(array $entity_info) {
+    $entity_type = $entity_info['entity_type'];
+    $uuid = !empty($entity_info['uuid']) ? $entity_info['uuid'] : NULL;
+    if ($uuid) {
+      return $this->entityManager()->loadEntityByUuid($entity_type, $uuid);
+    }
+    else {
+      return $this->entityManager()->getStorage($entity_type)
+        ->load($entity_info['id']);
+    }
+  }
+
 }
diff --git a/core/modules/system/tests/modules/entity_reference_selection_test/config/schema/entity_reference_selection_test.schema.yml b/core/modules/system/tests/modules/entity_reference_selection_test/config/schema/entity_reference_selection_test.schema.yml
new file mode 100644
index 0000000000..af69ac5574
--- /dev/null
+++ b/core/modules/system/tests/modules/entity_reference_selection_test/config/schema/entity_reference_selection_test.schema.yml
@@ -0,0 +1,3 @@
+# Schema for the entity reference 'entity_test_all_except_host' selection handler settings.
+entity_reference_selection.entity_test_all_except_host:
+  type: entity_reference_selection.default
diff --git a/core/modules/system/tests/modules/entity_reference_selection_test/entity_reference_selection_test.info.yml b/core/modules/system/tests/modules/entity_reference_selection_test/entity_reference_selection_test.info.yml
new file mode 100644
index 0000000000..e7ea55f005
--- /dev/null
+++ b/core/modules/system/tests/modules/entity_reference_selection_test/entity_reference_selection_test.info.yml
@@ -0,0 +1,8 @@
+name: "Entity Reference Selection plugin test"
+type: module
+description: "Support module for testing entity reference selection plugins."
+core: 8.x
+package: Testing
+version: VERSION
+dependencies:
+  - entity_test
diff --git a/core/modules/system/tests/modules/entity_reference_selection_test/src/Plugin/EntityReferenceSelection/AllExceptHostEntity.php b/core/modules/system/tests/modules/entity_reference_selection_test/src/Plugin/EntityReferenceSelection/AllExceptHostEntity.php
new file mode 100644
index 0000000000..4a8c006602
--- /dev/null
+++ b/core/modules/system/tests/modules/entity_reference_selection_test/src/Plugin/EntityReferenceSelection/AllExceptHostEntity.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Drupal\entity_reference_selection_test\Plugin\EntityReferenceSelection;
+
+use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
+use Drupal\entity_test\Entity\EntityTest;
+
+/**
+ * Allows access to all entities except for the host entity.
+ *
+ * @EntityReferenceSelection(
+ *   id = "entity_test_all_except_host",
+ *   label = @Translation("All except host entity."),
+ *   entity_types = {"entity_test"},
+ *   group = "entity_test_all_except_host"
+ * )
+ */
+class AllExceptHostEntity extends DefaultSelection {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
+    $query = parent::buildEntityQuery($match, $match_operator);
+
+    /** @var \Drupal\Core\Entity\EntityInterface $entity */
+    $entity = $this->configuration['entity'];
+
+    // The host entity should be the same type as the entity type this plugin
+    // supports.
+    if ($entity instanceof EntityTest) {
+      $target_type = $this->configuration['target_type'];
+      $entity_type = $this->entityManager->getDefinition($target_type);
+      $query->condition($entity_type->getKey('id'), $entity->id(), '<>');
+    }
+
+    return $query;
+  }
+
+}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php b/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php
index 511dee6e32..4cab2afc34 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php
@@ -6,6 +6,8 @@ use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
 use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
 use Drupal\simpletest\ContentTypeCreationTrait;
 use Drupal\simpletest\NodeCreationTrait;
+use Drupal\Core\Entity\Entity\EntityFormDisplay;
+use Drupal\entity_test\Entity\EntityTest;
 
 /**
  * Tests the output of entity reference autocomplete widgets.
@@ -21,7 +23,7 @@ class EntityReferenceAutocompleteWidgetTest extends JavascriptTestBase {
   /**
    * {@inheritdoc}
    */
-  public static $modules = ['node'];
+  public static $modules = ['node', 'entity_test', 'entity_reference_selection_test'];
 
   /**
    * {@inheritdoc}
@@ -99,4 +101,49 @@ class EntityReferenceAutocompleteWidgetTest extends JavascriptTestBase {
     $assert_session->pageTextNotContains('Page test');
   }
 
+  /**
+   * Tests that the autocomplete widget knows about the entity its attached to.
+   *
+   * Ensures that the entity the autocomplete widget stores the entity it is
+   * rendered on, and is available in the autocomplete results AJAX request.
+   */
+  public function testEntityReferenceAutocompleteWidgetAttachedEntity() {
+    $user = $this->drupalCreateUser([
+      'administer entity_test content',
+    ]);
+    $this->drupalLogin($user);
+
+    $field_name = 'field_test';
+    $this->createEntityReferenceField('entity_test', 'entity_test', $field_name, $field_name, 'entity_test', 'entity_test_all_except_host', ['target_bundles' => ['entity_test']]);
+    $form_display = EntityFormDisplay::load('entity_test.entity_test.default');
+    $form_display->setComponent($field_name, [
+      'type' => 'entity_reference_autocomplete',
+      'settings' => [
+        'match_operator' => 'CONTAINS',
+      ],
+    ]);
+    $form_display->save();
+
+    $host = EntityTest::create(['name' => 'dark green']);
+    $host->save();
+    $other = EntityTest::create(['name' => 'dark blue']);
+    $other->save();
+
+    $this->drupalGet($host->toUrl('edit-form'));
+    $this->assertSession()->statusCodeEquals(200);
+
+    // Trigger the autocomplete.
+    $page = $this->getSession()->getPage();
+    $autocomplete_field = $page->findField($field_name . '[0][target_id]');
+    $autocomplete_field->setValue('dark');
+    $this->getSession()->getDriver()->keyDown($autocomplete_field->getXpath(), ' ');
+    $this->assertSession()->waitOnAutocomplete();
+
+    // Check the autocomplete results.
+    $results = $page->findAll('css', '.ui-autocomplete li');
+    $this->assertCount(1, $results);
+    $this->assertSession()->elementTextNotContains('css', '.ui-autocomplete li', 'dark green');
+    $this->assertSession()->elementTextContains('css', '.ui-autocomplete li', 'dark blue');
+  }
+
 }
