diff --git a/includes/theme.inc b/includes/theme.inc
index 7fad5f388dcb18147b8b402e4625a8340ac60a47..21543426b0ccf56a6b55b22401054d6354973d0d 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -1199,10 +1199,10 @@ function drupal_find_theme_templates($cache, $extension, $path) {
     if (strpos($file->uri, str_replace($subtheme_paths, '', $file->uri)) !== 0) {
       continue;
     }
-    // Chop off the remaining extensions if there are any. $template already
-    // has the rightmost extension removed, but there might still be more,
-    // such as with .tpl.php, which still has .tpl in $template at this point.
-    if (($pos = strpos($template, '.')) !== FALSE) {
+    // Chop off the remaining '.tpl' extension. $template already has the
+    // rightmost extension removed, but there might still be more, such as with
+    // .tpl.php, which still has .tpl in $template at this point.
+    if (($pos = strpos($template, '.tpl')) !== FALSE) {
       $template = substr($template, 0, $pos);
     }
     // Transform - in filenames to _ to match function naming scheme
@@ -1214,6 +1214,19 @@ function drupal_find_theme_templates($cache, $extension, $path) {
         'path' => dirname($file->uri),
       );
     }
+
+    // Match templates based on the 'template' filename.
+    foreach ($cache as $hook => $info) {
+      if (isset($info['template'])) {
+        $template_candidates = array($info['template'], str_replace($info['theme path'] . '/', '', $info['template']));
+        if (in_array($template, $template_candidates)) {
+          $implementations[$hook] = array(
+            'template' => $template,
+            'path' => dirname($file->uri),
+          );
+        }
+      }
+    }
   }
 
   // Find templates that implement possible "suggestion" variants of registered
diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test
index 7c6898965994cb83a73a3b7fbaca79069a2478e5..0cecec0d28598d5255687e1946aaa62fc54943ea 100644
--- a/modules/simpletest/tests/theme.test
+++ b/modules/simpletest/tests/theme.test
@@ -101,6 +101,15 @@ class ThemeUnitTest extends DrupalWebTestCase {
     $this->drupalGet('theme-test/suggestion');
     variable_set('preprocess_css', 0);
   }
+
+  /**
+   * Ensures a themes template is overrideable based on the 'template' filename.
+   */
+  function testTemplateOverride() {
+    variable_set('theme_default', 'test_theme');
+    $this->drupalGet('theme-test/template-test');
+    $this->assertText('Success: Template overridden.', t('Template overridden by defined \'template\' filename.'));
+  }
 }
 
 /**
diff --git a/modules/simpletest/tests/theme_test.module b/modules/simpletest/tests/theme_test.module
index 160d192dd82a565858bdafc82dab953b2b952ef9..e95f62214aed4c0dfccfa699ec5b8c3071feb812 100644
--- a/modules/simpletest/tests/theme_test.module
+++ b/modules/simpletest/tests/theme_test.module
@@ -1,5 +1,16 @@
 <?php
 
+/**
+ * Implements hook_theme().
+ */
+function theme_test_theme($existing, $type, $theme, $path) {
+  $items['theme_test_template_test'] = array(
+    'template' => 'theme_test.template_test',
+  );
+
+  return $items;
+}
+
 /**
  * Implements hook_menu().
  */
@@ -23,6 +34,11 @@ function theme_test_menu() {
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
   );
+  $items['theme-test/template-test'] = array(
+    'page callback' => 'theme_test_template_test_page_callback',
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
   return $items;
 }
 
@@ -69,6 +85,13 @@ function theme_test_hook_init_page_callback() {
   return $GLOBALS['theme_test_output'];
 }
 
+/**
+ * Menu callback for testing template overridding based on filename.
+ */
+function theme_test_template_test_page_callback() {
+  return theme('theme_test_template_test');
+}
+
 /**
  * Custom theme callback.
  */
diff --git a/modules/simpletest/tests/theme_test.template_test.tpl.php b/modules/simpletest/tests/theme_test.template_test.tpl.php
new file mode 100644
index 0000000000000000000000000000000000000000..cde8faadd3c38e5b5f555af2a963ffe10d647647
--- /dev/null
+++ b/modules/simpletest/tests/theme_test.template_test.tpl.php
@@ -0,0 +1,2 @@
+<!-- Output for Theme API test -->
+Fail: Template not overridden.
diff --git a/themes/tests/test_theme/theme_test.template_test.tpl.php b/themes/tests/test_theme/theme_test.template_test.tpl.php
new file mode 100644
index 0000000000000000000000000000000000000000..d4409bf16e0a3962ad22e5f1fda1d629194fb7bd
--- /dev/null
+++ b/themes/tests/test_theme/theme_test.template_test.tpl.php
@@ -0,0 +1,2 @@
+<!-- Output for Theme API test -->
+Success: Template overridden.