diff --git includes/common.inc includes/common.inc
index 382d047..4832e03 100644
--- includes/common.inc
+++ includes/common.inc
@@ -5940,7 +5940,7 @@ function drupal_common_theme() {
       'render element' => 'element',
     ),
     'menu_local_tasks' => array(
-      'variables' => array(),
+      'variables' => array('primary' => array(), 'secondary' => array()),
     ),
     // from form.inc
     'select' => array(
diff --git includes/menu.inc includes/menu.inc
index bae3750..ec19da4 100644
--- includes/menu.inc
+++ includes/menu.inc
@@ -2045,22 +2045,35 @@ function menu_tab_root_path() {
 }
 
 /**
- * Returns renderable local tasks.
+ * Returns a renderable element for the primary and secondary tabs.
+ */
+function menu_local_tabs() {
+  return array(
+    '#theme' => 'menu_local_tasks',
+    '#primary' => menu_primary_local_tasks(),
+    '#secondary' => menu_secondary_local_tasks(),
+  );
+}
+
+/**
+ * Returns HTML for primary and secondary local tasks.
  *
  * @ingroup themeable
  */
-function theme_menu_local_tasks() {
-  $output = array();
+function theme_menu_local_tasks(&$variables) {
+  $output = '';
 
-  if ($primary = menu_primary_local_tasks()) {
-    $primary['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2><ul class="tabs primary">';
-    $primary['#suffix'] = '</ul>';
-    $output[] = $primary;
-  }
-  if ($secondary = menu_secondary_local_tasks()) {
-    $secondary['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2><ul class="tabs secondary">';
-    $secondary['#suffix'] = '</ul>';
-    $output[] = $secondary;
+  if (!empty($variables['primary'])) {
+    $variables['primary']['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2>';
+    $variables['primary']['#prefix'] .= '<ul class="tabs primary">';
+    $variables['primary']['#suffix'] = '</ul>';
+    $output .= drupal_render($variables['primary']);
+  }
+  if (!empty($variables['secondary'])) {
+    $variables['secondary']['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2>';
+    $variables['secondary']['#prefix'] .= '<ul class="tabs secondary">';
+    $variables['secondary']['#suffix'] = '</ul>';
+    $output .= drupal_render($variables['secondary']);
   }
 
   return $output;
diff --git includes/theme.inc includes/theme.inc
index 658128c..8c3d121 100644
--- includes/theme.inc
+++ includes/theme.inc
@@ -2268,7 +2268,7 @@ function template_preprocess_page(&$variables) {
   $variables['action_links']      = menu_local_actions();
   $variables['site_name']         = (theme_get_setting('toggle_name') ? filter_xss_admin(variable_get('site_name', 'Drupal')) : '');
   $variables['site_slogan']       = (theme_get_setting('toggle_slogan') ? filter_xss_admin(variable_get('site_slogan', '')) : '');
-  $variables['tabs']              = theme('menu_local_tasks');
+  $variables['tabs']              = menu_local_tabs();
   $variables['title']             = drupal_get_title();
 
   if ($node = menu_get_object()) {
diff --git modules/overlay/overlay.module modules/overlay/overlay.module
index 6c71fee..0a45ff5 100644
--- modules/overlay/overlay.module
+++ modules/overlay/overlay.module
@@ -350,7 +350,7 @@ function template_process_overlay(&$variables) {
  */
 function overlay_preprocess_page(&$variables) {
   if (overlay_get_mode() == 'child') {
-    unset($variables['tabs'][0]);
+    unset($variables['tabs']['#primary']);
   }
 }
 
diff --git themes/garland/page.tpl.php themes/garland/page.tpl.php
index 02d3e0e..ce0fed9 100644
--- themes/garland/page.tpl.php
+++ themes/garland/page.tpl.php
@@ -47,8 +47,8 @@
             <h1<?php print $tabs ? ' class="with-tabs"' : '' ?>><?php print $title ?></h1>
           <?php endif; ?>
           <?php print render($title_suffix); ?>
-          <?php if ($tabs): ?><h2 class="element-invisible"><?php print t('Primary tabs'); ?></h2><ul class="tabs primary"><?php print render($tabs) ?></ul></div><?php endif; ?>
-          <?php if ($tabs2): ?><h2 class="element-invisible"><?php print t('Secondary tabs'); ?></h2><ul class="tabs secondary"><?php print render($tabs2) ?></ul><?php endif; ?>
+          <?php if ($tabs): ?><?php print render($tabs); ?></div><?php endif; ?>
+          <?php print render($tabs2); ?>
           <?php print $messages; ?>
           <?php print render($page['help']); ?>
           <?php if ($action_links): ?><ul class="action-links"><?php print render($action_links); ?></ul><?php endif; ?>
diff --git themes/garland/template.php themes/garland/template.php
index 37d76b6..c2ac4e6 100644
--- themes/garland/template.php
+++ themes/garland/template.php
@@ -59,7 +59,13 @@ function garland_process_html(&$vars) {
  * Override or insert variables into the page template.
  */
 function garland_preprocess_page(&$vars) {
-  $vars['tabs2'] = menu_secondary_local_tasks();
+  // Move secondary tabs into a separate variable.
+  $vars['tabs2'] = array(
+    '#theme' => 'menu_local_tasks',
+    '#secondary' => $vars['tabs']['#secondary'],
+  );
+  unset($vars['tabs']['#secondary']);
+
   if (isset($vars['main_menu'])) {
     $vars['primary_nav'] = theme('links__system_main_menu', array(
       'links' => $vars['main_menu'],
@@ -139,11 +145,3 @@ function garland_preprocess_region(&$vars) {
     $vars['classes_array'][] = 'clearfix';
   }
 }
-
-/**
- * Returns the rendered local tasks. The default implementation renders
- * them as tabs. Overridden to split the secondary tasks.
- */
-function garland_menu_local_tasks() {
-  return menu_primary_local_tasks();
-}
diff --git themes/seven/page.tpl.php themes/seven/page.tpl.php
index 0606e8f..c81c3ab 100644
--- themes/seven/page.tpl.php
+++ themes/seven/page.tpl.php
@@ -9,17 +9,11 @@
       <h1 class="page-title"><?php print $title; ?></h1>
     <?php endif; ?>
     <?php print render($title_suffix); ?>
-    <?php if ($primary_local_tasks): ?>
-      <h2 class="element-invisible"><?php print t('Primary tabs'); ?></h2>
-      <ul class="tabs primary"><?php print render($primary_local_tasks); ?></ul>
-    <?php endif; ?>
+    <?php print render($primary_local_tasks); ?>
   </div>
 
   <div id="page">
-    <?php if ($secondary_local_tasks): ?>
-      <h2 class="element-invisible"><?php print t('Secondary tabs'); ?></h2>
-      <ul class="tabs secondary"><?php print render($secondary_local_tasks); ?></ul>
-    <?php endif; ?>
+    <?php print render($secondary_local_tasks); ?>
 
     <div id="content" class="clearfix">
       <?php if ($messages): ?>
diff --git themes/seven/style.css themes/seven/style.css
index 07ef649..d62327b 100644
--- themes/seven/style.css
+++ themes/seven/style.css
@@ -876,7 +876,6 @@ ol.task-list li.done {
   background-color: #fff;
   padding-top: 15px;
 }
-.overlay .primary,
 .overlay #branding h1.page-title,
 .overlay #left,
 .overlay #footer {
diff --git themes/seven/template.php themes/seven/template.php
index 40862ff..ea54500 100644
--- themes/seven/template.php
+++ themes/seven/template.php
@@ -27,8 +27,12 @@ function seven_preprocess_html(&$vars) {
  * Override or insert variables into the page template.
  */
 function seven_preprocess_page(&$vars) {
-  $vars['primary_local_tasks'] = menu_primary_local_tasks();
-  $vars['secondary_local_tasks'] = menu_secondary_local_tasks();
+  $vars['primary_local_tasks'] = $vars['tabs'];
+  unset($vars['primary_local_tasks']['#secondary']);
+  $vars['secondary_local_tasks'] = array(
+    '#theme' => 'menu_local_tasks',
+    '#secondary' => $vars['tabs']['#secondary'],
+  );
 }
 
 /**
