diff --git a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
index 4273a41..49b2fcc 100644
--- a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
+++ b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
@@ -37,6 +37,7 @@ public function getInfo() {
     $info['#target_type'] = NULL;
     $info['#selection_handler'] = 'default';
     $info['#selection_settings'] = array();
+    $info['#host_entity_id'] = NULL;
     $info['#tags'] = FALSE;
     $info['#autocreate'] = NULL;
     // This should only be set to FALSE if proper validation by the selection
@@ -131,6 +132,7 @@ public static function processEntityAutocomplete(array &$element, FormStateInter
       'target_type' => $element['#target_type'],
       'selection_handler' => $element['#selection_handler'],
       'selection_settings_key' => $selection_settings_key,
+      'host_entity_id' => $element['#host_entity_id'],
     );
 
     return $element;
diff --git a/core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php b/core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php
index 3e350b0..92d3c83 100644
--- a/core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php
+++ b/core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php
@@ -44,6 +44,8 @@ public function __construct(SelectionPluginManagerInterface $selection_manager)
    *   An array of settings that will be passed to the selection handler.
    * @param string $string
    *   (optional) The label of the entity to query by.
+   * @param \Drupal\Core\Entity\EntityInterface $host_entity
+   *   (optional) The referencing entity, if any. Defaults to NULL.
    *
    * @return array
    *   An array of matched entity labels, in the format required by the AJAX
@@ -54,13 +56,14 @@ public function __construct(SelectionPluginManagerInterface $selection_manager)
    *
    * @see \Drupal\system\Controller\EntityAutocompleteController
    */
-  public function getMatches($target_type, $selection_handler, $selection_settings, $string = '') {
+  public function getMatches($target_type, $selection_handler, $selection_settings, $string = '', EntityInterface $host_entity = NULL) {
     $matches = array();
 
     $options = array(
       'target_type' => $target_type,
       'handler' => $selection_handler,
       'handler_settings' => $selection_settings,
+      'entity' => $host_entity,
     );
     $handler = $this->selectionManager->getInstance($options);
 
diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
index b108bb4..2a6a36d 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
@@ -122,6 +122,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
         'field' => '_none',
       ),
       'auto_create' => FALSE,
+      'allow_self_reference' => TRUE,
     );
 
     if ($entity_type->hasKey('bundle')) {
@@ -207,6 +208,12 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
       }
     }
 
+    $form['allow_self_reference'] = array(
+      '#type' => 'checkbox',
+      '#title' => $this->t('Allow an entity to reference itself'),
+      '#default_value' => isset($this->configuration['handler_settings']['allow_self_reference']) ? $this->configuration['handler_settings']['allow_self_reference'] : TRUE,
+    );
+
     return $form;
   }
 
@@ -360,6 +367,11 @@ protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS')
       $query->condition($label_key, $match, $match_operator);
     }
 
+    // Disallow self-references if possible.
+    if (isset($this->configuration['entity']) && isset($handler_settings['allow_self_reference']) && !$handler_settings['allow_self_reference']) {
+      $query->condition($entity_type->getKey('id'), $this->configuration['entity']->id(), '<>');
+    }
+
     // Add entity-access tag.
     $query->addTag($target_type . '_access');
 
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 79eff67..fa5cbf3 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php
@@ -113,6 +113,11 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
       );
     }
 
+    // Pass the ID of the referencing entity if it is available.
+    if (!$entity->isNew()) {
+      $element['#host_entity_id'] = $entity->id();
+    }
+
     return array('target_id' => $element);
   }
 
diff --git a/core/modules/system/src/Controller/EntityAutocompleteController.php b/core/modules/system/src/Controller/EntityAutocompleteController.php
index 44b6596..57f1984 100644
--- a/core/modules/system/src/Controller/EntityAutocompleteController.php
+++ b/core/modules/system/src/Controller/EntityAutocompleteController.php
@@ -73,6 +73,8 @@ public static function create(ContainerInterface $container) {
    * @param string $selection_settings_key
    *   The hashed key of the key/value entry that holds the selection handler
    *   settings.
+   * @param string $host_entity_id
+   *   (optional) The ID of the referencing entity, if any. Defaults to none.
    *
    * @return \Symfony\Component\HttpFoundation\JsonResponse
    *   The matched entity labels as a JSON response.
@@ -81,8 +83,10 @@ public static function create(ContainerInterface $container) {
    *   Thrown if the selection settings key is not found in the key/value store
    *   or if it does not match the stored data.
    */
-  public function handleAutocomplete(Request $request, $target_type, $selection_handler, $selection_settings_key) {
+  public function handleAutocomplete(Request $request, $target_type, $selection_handler, $selection_settings_key, $host_entity_id = '') {
     $matches = array();
+    $host_entity = NULL;
+
     // Get the typed string from the URL, if it exists.
     if ($input = $request->query->get('q')) {
       $typed_string = Tags::explode($input);
@@ -105,7 +109,14 @@ public function handleAutocomplete(Request $request, $target_type, $selection_ha
         throw new AccessDeniedHttpException();
       }
 
-      $matches = $this->matcher->getMatches($target_type, $selection_handler, $selection_settings, $typed_string);
+      if ($host_entity_id) {
+        $host_entity = $this->entityTypeManager()->getStorage($target_type)->load($host_entity_id);
+        if (!$host_entity || !$host_entity->access('view')) {
+          throw new AccessDeniedHttpException();
+        }
+      }
+
+      $matches = $this->matcher->getMatches($target_type, $selection_handler, $selection_settings, $typed_string, $host_entity);
     }
 
     return new JsonResponse($matches);
diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml
index e6108ac..7004db4 100644
--- a/core/modules/system/system.routing.yml
+++ b/core/modules/system/system.routing.yml
@@ -467,8 +467,9 @@ system.admin_content:
     _permission: 'access administration pages'
 
 system.entity_autocomplete:
-  path: '/entity_reference_autocomplete/{target_type}/{selection_handler}/{selection_settings_key}'
+  path: '/entity_reference_autocomplete/{target_type}/{selection_handler}/{selection_settings_key}/{host_entity_id}'
   defaults:
     _controller: '\Drupal\system\Controller\EntityAutocompleteController::handleAutocomplete'
+    host_entity_id: ''
   requirements:
     _access: 'TRUE'
