diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php
index 076cfd3..3e02236 100644
--- a/core/lib/Drupal/Core/Template/Attribute.php
+++ b/core/lib/Drupal/Core/Template/Attribute.php
@@ -30,7 +30,7 @@
  *  // Produces <cat class="cat black-cat white-cat black-white-cat" id="socks">
  * @endcode
  */
-class Attribute implements \ArrayAccess, \IteratorAggregate {
+class Attribute extends \Twig_Markup implements \ArrayAccess, \IteratorAggregate {
 
   /**
    * Stores the attribute data.
diff --git a/core/lib/Drupal/Core/Template/AttributeValueBase.php b/core/lib/Drupal/Core/Template/AttributeValueBase.php
index df187df..4411c0b 100644
--- a/core/lib/Drupal/Core/Template/AttributeValueBase.php
+++ b/core/lib/Drupal/Core/Template/AttributeValueBase.php
@@ -12,7 +12,7 @@
  *
  * @see Drupal\Core\Template\Attribute
  */
-abstract class AttributeValueBase {
+abstract class AttributeValueBase extends \Twig_Markup {
 
   /**
    * Whether this attribute hsa been printed already.
@@ -69,6 +69,8 @@ public function printed() {
   /**
    * Implements the magic __toString() method.
    */
-  abstract function __toString();
+  public function __toString() {
+    return parent::__toString();
+  }
 
 }
diff --git a/core/lib/Drupal/Core/Template/TwigFactory.php b/core/lib/Drupal/Core/Template/TwigFactory.php
index 4bb297e..a7a9e5e 100644
--- a/core/lib/Drupal/Core/Template/TwigFactory.php
+++ b/core/lib/Drupal/Core/Template/TwigFactory.php
@@ -50,9 +50,7 @@ public static function get() {
         // @todo ensure garbage collection of expired files.
         'cache' => TRUE,
         'base_template_class' => 'Drupal\Core\Template\TwigTemplate',
-        // @todo Remove in followup issue
-        // @see http://drupal.org/node/1712444.
-        'autoescape' => FALSE,
+        'autoescape' => TRUE,
         // @todo Remove in followup issue
         // @see http://drupal.org/node/1806538.
         'strict_variables' => FALSE,
@@ -77,7 +75,9 @@ public static function get() {
       // @todo re-add unset => twig_unset if this is really needed
     );
     $filters = array(
-      't' => 't'
+      't' => 't',
+      // Helper filter used to replace twig's original raw() filter
+      'twig_raw' => 'twig_raw',
     );
 
     // These functions will receive a TwigReference object, if a render array is detected
diff --git a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
index 0cf5465..c42eaa1 100644
--- a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
+++ b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
@@ -58,6 +58,8 @@ function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
    * We use this to inject a call to render -> twig_render()
    * before anything is printed.
    *
+   * We also change the 'raw' filter to our own 'twig_raw' filter.
+   *
    * @see twig_render
    */
   function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
@@ -70,6 +72,10 @@ function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
         $node->getLine()
       );
     }
+    else if ($node instanceof \Twig_Node_Expression_Filter && 'raw' == $node->getNode('filter')->getAttribute('value')) {
+      // Use our own twig_raw filter that returns Twig_Markup
+      $node->getNode('filter')->setAttribute('value', 'twig_raw');
+    }
 
     if ($this->isReference) {
       if ($node instanceof \Twig_Node_Expression_Name) {
diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine
index abc4407..0a9f901 100644
--- a/core/themes/engines/twig/twig.engine
+++ b/core/themes/engines/twig/twig.engine
@@ -45,6 +45,12 @@ function twig_init($template) {
  *   The output generated by the template.
  */
 function twig_render_template($template_file, $variables) {
+  // Mark all strings in $variables as safe
+  foreach ($variables as $key => $val) {
+    if (is_string($val)) {
+      $variables[$key]=new Twig_Markup($val, 'UTF-8');
+    }
+  }
   $variables['_references']=array();
   return drupal_container()->get('twig')->loadTemplate($template_file)->render($variables);
 }
@@ -79,7 +85,7 @@ function twig_render($arg) {
     return null;
   }
 
-  // Keep Twig_Markup objects intact to prepare for later autoescaping support
+  // Keep Twig_Markup objects intact to support autoescaping
   if ($arg instanceOf Twig_Markup) {
     return $arg;
   }
@@ -96,7 +102,7 @@ function twig_render($arg) {
   }
 
   // This is a normal render array.
-  return render($arg);
+  return new Twig_Markup(render($arg), 'UTF-8');
 }
 
 /**
@@ -124,3 +130,21 @@ function twig_show($element) {
   }
   // @todo Add warning in else case
 }
+
+/**
+ * Replacement function for twig's raw filter
+ *
+ * This needs to be used, because the default raw
+ * filter gets optimized out.
+ *
+ * As we wrap everything that is printed in twig_render()
+ * we need to return Twig_Markup instead.
+ * This allows to hold the information that a value was
+ * marked 'raw' by the template author.
+ *
+ * @see TwigNodeVisitor
+ *
+ */
+function twig_raw($string) {
+  return new Twig_Markup($string, 'UTF-8');
+}
