diff --git a/core/includes/form.inc b/core/includes/form.inc
index 36e1654..9a1f9f6 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -3871,7 +3871,14 @@ function form_validate_machine_name(&$element, &$form_state) {
   // Verify that the machine name is unique.
   if ($element['#default_value'] !== $element['#value']) {
     $function = $element['#machine_name']['exists'];
-    if (call_user_func($function, $element['#value'], $element, $form_state)) {
+    $id = array();
+    // Certain configuration entities prefix the machine name so add these if
+    // required.
+    if (!empty($element['#machine_name']['id_prefix'])) {
+      $id = $element['#machine_name']['id_prefix'];
+    }
+    $id[] = $element['#value'];
+    if (call_user_func($function, implode('.', $id), $element, $form_state)) {
       form_error($element, t('The machine-readable name is already in use. It must be unique.'));
     }
   }
diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php
index 335a9cd..ca0cc42 100644
--- a/core/modules/block/lib/Drupal/block/BlockFormController.php
+++ b/core/modules/block/lib/Drupal/block/BlockFormController.php
@@ -37,6 +37,7 @@ public function form(array $form, array &$form_state) {
         'exists' => 'block_load',
         'replace_pattern' => '[^a-z0-9_.]+',
         'source' => array('settings', 'label'),
+        'id_prefix' => array($entity->get('theme')),
       ),
       '#required' => TRUE,
       '#disabled' => !$entity->isNew(),
@@ -175,6 +176,7 @@ public function form(array $form, array &$form_state) {
       '#empty_value' => BLOCK_REGION_NONE,
       '#options' => system_region_list($entity->get('theme'), REGIONS_VISIBLE),
     );
+
     return $form;
   }
 
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
index 75bcb39..8b9d741 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
@@ -138,6 +138,33 @@ function testBlock() {
   }
 
   /**
+   * Test creating a block with a duplicate machine name.
+   */
+  function testDuplicateMachineName() {
+    // Configure the 'Powered by Drupal' block.
+    $block = array();
+    $block['id'] = 'system_powered_by_block';
+    $block['settings[label]'] = $this->randomName(8);
+    $block['machine_name'] = strtolower($this->randomName(8));
+    $block['theme'] = config('system.theme')->get('default');
+    $block['region'] = 'header';
+
+    // Set block title to confirm that interface works and override any custom titles.
+    $this->drupalPost('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('settings[label]' => $block['settings[label]'], 'machine_name' => $block['machine_name'], 'region' => $block['region']), t('Save block'));
+    $this->assertText(t('The block configuration has been saved.'), 'Block title set.');
+
+    // Reuse the machine name and change the plugin id to the 'Help' block.
+    $block['id'] = 'system_help_block';
+    $block['region'] = 'help';
+    $this->drupalPost('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('settings[label]' => $block['settings[label]'], 'machine_name' => $block['machine_name'], 'region' => $block['region']), t('Save block'));
+    $this->assertText(t('The machine-readable name is already in use. It must be unique.'));
+
+    // Check to see if the original block has been overwritten.
+    $instance = entity_load('block', $block['theme'] . '.' . $block['machine_name']);
+    $this->assertEqual($instance->get('plugin'), 'system_powered_by_block');
+  }
+
+  /**
    * Test block title display settings.
    */
   function testHideBlockTitle() {
