diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module
index 8e6e65b..d6b746a 100644
--- a/core/modules/overlay/overlay.module
+++ b/core/modules/overlay/overlay.module
@@ -99,6 +99,11 @@ function overlay_form_user_profile_form_alter(&$form, &$form_state) {
       '#description' => t('Show administrative pages on top of the page you started from.'),
       '#default_value' => isset($account->data['overlay']) ? $account->data['overlay'] : 1,
     );
+      // Record in $form_state whether the overlay was enabled for this user
+      // at the time the form was loaded, so we can check this in our custom
+      // submit handler.
+      $form_state['overlay']['originally_enabled'] = $form['overlay_control']['overlay']['#default_value'];
+      $form['#submit'][] = 'overlay_user_profile_form_submit';
   }
 }
 
@@ -112,6 +117,21 @@ function overlay_user_presave($account) {
 }
 
 /**
+ * Submit handler for the overlay toggle on the user account page.
+ */
+function overlay_user_profile_form_submit($form, &$form_state) {
+  // If the current user just enabled the overlay for themselves, set a session
+  // variable which causes overlay_init() to redirect into the overlay
+  // immediately on the next page request.
+  global $user;
+  if ($user->uid == $form_state['user']->uid && !empty($form_state['values']['overlay']) && empty($form_state['overlay']['originally_enabled'])) {
+    $_SESSION['overlay_enable_redirect'] = array(
+      'parent_path' => 'user/' . $user->uid,
+    );
+  }
+}
+
+/**
  * Implements hook_init().
  *
  * Determine whether the current page request is destined to appear in the
@@ -129,11 +149,26 @@ function overlay_init() {
   $use_overlay = !isset($user->data['overlay']) || $user->data['overlay'];
   if (empty($mode) && user_access('access overlay') && $use_overlay) {
     $current_path = current_path();
-    // After overlay is enabled on the modules page, redirect to
-    // <front>#overlay=admin/modules to actually enable the overlay.
+    // If the overlay has just been enabled on the current page (for example,
+    // if the Overlay module was just installed at admin/modules), setting
+    // $_SESSION['overlay_enable_redirect'] to a value that evaluates to TRUE
+    // will force the overlay to open immediately. The default behavior if this
+    // session variable is set is to redirect to the front page of the site,
+    // with the current page in an overlay above that. If the calling code
+    // instead sets $_SESSION['overlay_enable_redirect'] to an array with
+    // optional elements 'parent_path' and 'child_path', then the page that
+    // appears underneath the overlay ('parent_path') and/or the page that
+    // appears inside the overlay ('child_path') can be overridden.
     if (isset($_SESSION['overlay_enable_redirect']) && $_SESSION['overlay_enable_redirect']) {
+      $redirect = array(
+        'parent_path' => '<front>',
+        'child_path' => $current_path,
+      );
+      if (is_array($_SESSION['overlay_enable_redirect'])) {
+        $redirect = $_SESSION['overlay_enable_redirect'] + $redirect;
+      }
       unset($_SESSION['overlay_enable_redirect']);
-      drupal_goto('<front>', array('fragment' => 'overlay=' . $current_path));
+      drupal_goto($redirect['parent_path'], array('fragment' => 'overlay=' . $redirect['child_path']));
     }
 
     if (isset($_GET['render']) && $_GET['render'] == 'overlay') {
