diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index bf8ef66..771cf17 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -6,6 +6,7 @@
 use Drupal\Core\Language\Language;
 
 use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Definition;
 use Symfony\Component\DependencyInjection\Reference;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
@@ -378,6 +379,31 @@ function install_begin_request(&$install_state) {
         'curl.CURLOPT_MAXREDIRS' => 3,
       ))
       ->addMethodCall('setUserAgent', array('Drupal (+http://drupal.org/)'));
+    $container->register('twig.loader.filesystem', 'Twig_Loader_Filesystem')
+      ->addArgument(DRUPAL_ROOT);
+    $container->setAlias('twig.loader', 'twig.loader.filesystem');
+
+    $container->register('twig', 'Drupal\Core\Template\TwigEnvironment')
+      ->addArgument(new Reference('twig.loader'))
+      ->addArgument(array(
+        // This is saved / loaded via drupal_php_storage().
+        // All files can be refreshed by clearing caches.
+        // @todo ensure garbage collection of expired files.
+        'cache' => settings()->get('twig_cache', TRUE),
+        'base_template_class' => 'Drupal\Core\Template\TwigTemplate',
+        // @todo Remove in followup issue
+        // @see http://drupal.org/node/1712444.
+        'autoescape' => FALSE,
+        // @todo Remove in followup issue
+        // @see http://drupal.org/node/1806538.
+        'strict_variables' => FALSE,
+        'debug' => settings()->get('twig_debug', FALSE),
+        'auto_reload' => settings()->get('twig_auto_reload', NULL),
+      ))
+      ->addMethodCall('addExtension', array(new Definition('Drupal\Core\Template\TwigExtension')))
+      // @todo Figure out what to do about debugging functions.
+      // @see http://drupal.org/node/1804998
+      ->addMethodCall('addExtension', array(new Definition('Twig_Extension_Debug')));
 
     Drupal::setContainer($container);
   }
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 8d527df..db76a1e 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2427,7 +2427,7 @@ function theme_feed_icon($variables) {
 }
 
 /**
- * Returns HTML for a generic HTML tag with attributes.
+ * Preprocess variables for html-tag.html.twig
  *
  * @param $variables
  *   An associative array containing:
@@ -2438,30 +2438,26 @@ function theme_feed_icon($variables) {
  *       - script: To load JavaScript.
  *     - #attributes: (optional) An array of HTML attributes to apply to the
  *       tag.
- *     - #value: (optional) A string containing tag content, such as inline
- *       CSS.
+ *     - #value: (optional) A string containing tag content, such as inline CSS.
  *     - #value_prefix: (optional) A string to prepend to #value, e.g. a CDATA
  *       wrapper prefix.
  *     - #value_suffix: (optional) A string to append to #value, e.g. a CDATA
  *       wrapper suffix.
  */
-function theme_html_tag($variables) {
+function template_preprocess_html_tag(&$variables) {
   $element = $variables['element'];
-  $attributes = isset($element['#attributes']) ? new Attribute($element['#attributes']) : '';
-  if (!isset($element['#value'])) {
-    return '<' . $element['#tag'] . $attributes . " />\n";
+  $variables['attributes'] = isset($element['#attributes']) ? new Attribute($element['#attributes']) : new Attribute(array());
+  if (isset($element['#value'])) {
+    $variables['value'] = $element['#value'];
   }
-  else {
-    $output = '<' . $element['#tag'] . $attributes . '>';
-    if (isset($element['#value_prefix'])) {
-      $output .= $element['#value_prefix'];
-    }
-    $output .= $element['#value'];
-    if (isset($element['#value_suffix'])) {
-      $output .= $element['#value_suffix'];
-    }
-    $output .= '</' . $element['#tag'] . ">\n";
-    return $output;
+  if (isset($element['#tag'])) {
+    $variables['tag'] = $element['#tag'];
+  }
+  if (isset($element['#value_prefix'])) {
+    $variables['value_prefix'] = $element['#value_prefix'];
+  }
+  if (isset($element['#value_prefix'])) {
+    $variables['value_suffix'] = $element['#value_suffix'];
   }
 }
 
@@ -3212,6 +3208,7 @@ function drupal_common_theme() {
     ),
     'html_tag' => array(
       'render element' => 'element',
+      'template' => 'html-tag',
     ),
     // From theme.maintenance.inc.
     'maintenance_page' => array(
