diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index 405de785e8..176601baa4 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -403,7 +403,7 @@ class SsiNode(Node):
             output = ''
         if self.parsed:
             try:
-                t = Template(output, name=filepath)
+                t = Template(output, name=filepath, engine=context.engine)
                 return t.render(context)
             except TemplateSyntaxError as e:
                 if settings.DEBUG:
diff --git a/django/template/engine.py b/django/template/engine.py
index 027d034877..5838877a9f 100644
--- a/django/template/engine.py
+++ b/django/template/engine.py
@@ -126,7 +126,7 @@ class Engine(object):
         Returns a compiled Template object for the given template code,
         handling template inheritance recursively.
         """
-        return Template(source, origin, name)
+        return Template(source, origin, name, engine=self)
 
     def get_template(self, template_name, dirs=_dirs_undefined):
         """