Index: django/template/loader_tags.py
===================================================================
--- django/template/loader_tags.py	(revision 2707)
+++ django/template/loader_tags.py	(working copy)
@@ -50,6 +50,8 @@
             if self.parent_name_expr:
                 error_msg += " Got this from the %r variable." % self.parent_name_expr #TODO nice repr.
             raise TemplateSyntaxError, error_msg
+        if hasattr(parent, 'render'):
+            return parent
         try:
             source, origin = find_template_source(parent, self.template_dirs)
         except TemplateDoesNotExist:
@@ -137,8 +139,9 @@
 
     This tag may be used in two ways: ``{% extends "base" %}`` (with quotes)
     uses the literal value "base" as the name of the parent template to extend,
-    or ``{% extends variable %}`` uses the value of ``variable`` as the name
-    of the parent template to extend.
+    or ``{% extends variable %}`` uses the value of ``variable`` as either the
+    name of the parent template to extend (if it evaluates to a string,) or as
+    the parent tempate itelf (if it evaluates to a Template object).
     """
     bits = token.contents.split()
     if len(bits) != 2:
Index: tests/othertests/templates.py
===================================================================
--- tests/othertests/templates.py	(revision 2707)
+++ tests/othertests/templates.py	(working copy)
@@ -314,6 +314,12 @@
     # Three-level inheritance with {{ block.super }} from parent and grandparent
     'inheritance23': ("{% extends 'inheritance20' %}{% block first %}{{ block.super }}b{% endblock %}", {}, '1_ab3_'),
 
+    # Inheritance from local context without use of template loader
+    'inheritance24': ("{% extends context_template %}{% block first %}2{% endblock %}{% block second %}4{% endblock %}", {'context_template': template.Template("1{% block first %}_{% endblock %}3{% block second %}_{% endblock %}")}, '1234'),
+
+    # Inheritance from local context with variable parent template
+    'inheritance25': ("{% extends context_template.1 %}{% block first %}2{% endblock %}{% block second %}4{% endblock %}", {'context_template': [template.Template("Wrong"), template.Template("1{% block first %}_{% endblock %}3{% block second %}_{% endblock %}")]}, '1234'),
+
     ### I18N ##################################################################
 
     # {% spaceless %} tag
Index: docs/templates.txt
===================================================================
--- docs/templates.txt	(revision 2707)
+++ docs/templates.txt	(working copy)
@@ -368,9 +368,11 @@
 
 This tag may be used in two ways: ``{% extends "base" %}`` (with quotes) uses
 the literal value "base" as the name of the parent template to extend, or ``{%
-extends variable %}`` uses the value of ``variable`` as the name of the parent
-template to extend.
+extends variable %}`` uses the value of ``variable`` as either the name of the
+parent template to extend (if it evaluates to a string,) or as the parent
+tempate itelf (if it evaluates to a Template object).
 
+
 See `Template inheritance`_ for more information.
 
 filter
