diff --git a/core/includes/common.inc b/core/includes/common.inc
index a4805c0..e8c47bf 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -3858,7 +3858,21 @@ function drupal_render(&$elements) {
   // #theme_wrappers function(s) to prevent infinite recursion.
   if (isset($elements['#theme_wrappers']) && !isset($elements['#render_children'])) {
     foreach ($elements['#theme_wrappers'] as $theme_wrapper) {
-      $elements['#children'] = theme($theme_wrapper, $elements);
+      // If #theme and #theme_wrappers have a namespace conflict and expect two
+      // or more different values under a single attribute we disambiguate on
+      // behalf of #theme_wrappers by allowing wrapper specific overrides for
+      // element attributes in the format #wrapper_wrappername_attributename to
+      // override #attributename.
+      $wrapper_elements = $elements;
+      foreach ($wrapper_elements as $key => $value) {
+        if (strstr($key, '#wrapper_' . $theme_wrapper . '_')) {
+          $strlen = strlen('#wrapper_' . $theme_wrapper . '_');
+          $new_key = '#' . substr($key, $strlen);
+          $wrapper_elements[$new_key] = $wrapper_elements[$key];
+          unset($wrapper_elements[$key]);
+        }
+      }
+      $elements['#children'] = theme($theme_wrapper, $wrapper_elements);
     }
   }
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
index ec115e3..5468ed2 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
@@ -73,6 +73,48 @@ function testDrupalRenderBasics() {
         'expected' => '',
       ),
 
+      // Test that #theme and #theme_wrappers can co-exist on an element.
+      array(
+        'name' => '#theme and #theme_wrappers basic',
+        'value' => array(
+          '#theme' => 'common_test_foo',
+          '#foo' => 'foo',
+          '#bar' => 'bar',
+          '#theme_wrappers' => array('container'),
+          '#attributes' => array('class' => 'baz'),
+        ),
+        'expected' => '<div class="baz">foobar</div>',
+      ),
+      // Test that #theme_wrappers can disambiguate element attributes shared
+      // with rendering methods that build #children by using the alternate
+      // #theme_wrappers attribute override syntax
+      // #wrapper_wrappername_attributename.
+      array(
+        'name' => '#theme and #theme_wrappers attribute disambiguation',
+        'value' => array(
+          '#type' => 'link',
+          '#theme_wrappers' => array('container'),
+          '#wrapper_container_attributes' => array('class' => 'baz'),
+          '#attributes' => array('id' => 'foo'),
+          '#href' => 'http://drupal.org',
+          '#title' => 'bar',
+        ),
+        'expected' => '<div class="baz"><a href="http://drupal.org" id="foo">bar</a></div>',
+      ),
+      // Test that #theme_wrappers can disambiguate element attributes when the
+      // "base" attribute is not set for #theme.
+      array(
+        'name' => '#theme_wrappers attribute disambiguation with undefined #theme attribute',
+        'value' => array(
+          '#type' => 'link',
+          '#href' => 'http://drupal.org',
+          '#title' => 'foo',
+          '#theme_wrappers' => array('container'),
+          '#wrapper_container_attributes' => array('class' => 'baz'),
+        ),
+        'expected' => '<div class="baz"><a href="http://drupal.org">foo</a></div>',
+      ),
+
       // Test handling of #markup as a fallback for #theme hooks.
       // Simple #markup with no theme.
       array(
