diff --git a/core/core.services.yml b/core/core.services.yml
index 58db84c..956ac7b 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -1322,7 +1322,8 @@ services:
     tags:
       - { name: twig.extension, priority: 100 }
     calls:
-      - [setGenerators, ['@url_generator']]
+      - [setUrlGenerator, ['@url_generator']]
+      - [setThemeManager, ['@theme.manager']]
   # @todo Figure out what to do about debugging functions.
   # @see https://www.drupal.org/node/1804998
   twig.extension.debug:
diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index 1902113..d35f2da 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -15,6 +15,7 @@
 use Drupal\Component\Utility\SafeMarkup;
 use Drupal\Core\Render\RendererInterface;
 use Drupal\Core\Routing\UrlGeneratorInterface;
+use Drupal\Core\Theme\ThemeManagerInterface;
 use Drupal\Core\Url;
 
 /**
@@ -41,6 +42,13 @@ class TwigExtension extends \Twig_Extension {
   protected $renderer;
 
   /**
+   * The theme manager.
+   *
+   * @var \Drupal\Core\Theme\ThemeManagerInterface
+   */
+  protected $themeManager;
+
+  /**
    * Constructs \Drupal\Core\Template\TwigExtension.
    *
    * @param \Drupal\Core\Render\RendererInterface $renderer
@@ -58,16 +66,29 @@ public function __construct(RendererInterface $renderer) {
    *
    * @return $this
    */
-  public function setGenerators(UrlGeneratorInterface $url_generator) {
+  public function setUrlGenerator(UrlGeneratorInterface $url_generator) {
     $this->urlGenerator = $url_generator;
     return $this;
   }
 
   /**
+   * Sets the theme manager.
+   *
+   * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
+   *   The theme manager.
+   *
+   * @return $this
+   */
+  public function setThemeManager(ThemeManagerInterface $theme_manager) {
+    $this->themeManager = $theme_manager;
+    return $this;
+  }
+
+  /**
    * {@inheritdoc}
    */
   public function getFunctions() {
-    return array(
+    return [
       // This function will receive a renderable array, if an array is detected.
       new \Twig_SimpleFunction('render_var', array($this, 'renderVar')),
       // The url and path function are defined in close parallel to those found
@@ -77,8 +98,9 @@ public function getFunctions() {
       new \Twig_SimpleFunction('url_from_path', array($this, 'getUrlFromPath'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))),
       new \Twig_SimpleFunction('link', array($this, 'getLink')),
       new \Twig_SimpleFunction('file_url', 'file_create_url'),
-      new \Twig_SimpleFunction('attach_library', array($this, 'attachLibrary'))
-    );
+      new \Twig_SimpleFunction('attach_library', [$this, 'attachLibrary']),
+      new \Twig_SimpleFunction('active_theme', [$this, 'getActiveTheme']),
+    ];
   }
 
   /**
@@ -247,6 +269,16 @@ public function getLink($text, $url, array $attributes = []) {
   }
 
   /**
+   * Gets the name of the active theme.
+   *
+   * @return string
+   *   The name of the active theme.
+   */
+  public function getActiveTheme() {
+    return $this->themeManager->getActiveTheme()->getName();
+  }
+
+  /**
    * Determines at compile time whether the generated URL will be safe.
    *
    * Saves the unneeded automatic escaping for performance reasons.
diff --git a/core/modules/system/src/Tests/Theme/EngineTwigTest.php b/core/modules/system/src/Tests/Theme/EngineTwigTest.php
index 86b49e8..4a0b8ff 100644
--- a/core/modules/system/src/Tests/Theme/EngineTwigTest.php
+++ b/core/modules/system/src/Tests/Theme/EngineTwigTest.php
@@ -129,6 +129,15 @@ public function testTwigFileUrls() {
   }
 
   /**
+   * Tests the active_theme() function.
+   */
+  public function testActiveTheme() {
+    $this->drupalGet('/twig-theme-test/active_theme');
+    $theme = \Drupal::service('theme.manager')->getActiveTheme()->getName();
+    $this->assertRaw('<div>active theme: ' . $theme . '</div>');
+  }
+
+  /**
    * Tests the attach of asset libraries.
    */
   public function testTwigAttachLibrary() {
diff --git a/core/modules/system/tests/modules/twig_theme_test/src/TwigThemeTestController.php b/core/modules/system/tests/modules/twig_theme_test/src/TwigThemeTestController.php
index 040b521..c26b7a9 100644
--- a/core/modules/system/tests/modules/twig_theme_test/src/TwigThemeTestController.php
+++ b/core/modules/system/tests/modules/twig_theme_test/src/TwigThemeTestController.php
@@ -85,4 +85,11 @@ public function registryLoaderRender() {
     return array('#theme' => 'twig_registry_loader_test');
   }
 
+  /**
+   * Menu callback for testing the active theme function.
+   */
+  public function activeThemeRender() {
+    return ['#theme' => 'twig_theme_test_active_theme'];
+  }
+
 }
diff --git a/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.active_theme.html.twig b/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.active_theme.html.twig
new file mode 100644
index 0000000..fdf29fe
--- /dev/null
+++ b/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.active_theme.html.twig
@@ -0,0 +1 @@
+<div>active theme: {{ active_theme() }}</div>
diff --git a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
index 9aaccfa..04cfddf 100644
--- a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
+++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module
@@ -54,6 +54,10 @@ function twig_theme_test_theme($existing, $type, $theme, $path) {
     'variables' => array(),
     'template' => 'twig_theme_test.attach_library',
   );
+  $items['twig_theme_test_active_theme'] = [
+    'variables' => [],
+    'template' => 'twig_theme_test.active_theme',
+  ];
   return $items;
 }
 
diff --git a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.routing.yml b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.routing.yml
index 4cdfeca..f5d5e71 100644
--- a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.routing.yml
+++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.routing.yml
@@ -55,3 +55,10 @@ twig_theme_test_registry_loader:
     no_cache: TRUE
   requirements:
     _access: 'TRUE'
+
+twig_theme_test_active_theme:
+  path: '/twig-theme-test/active_theme'
+  defaults:
+    _controller: '\Drupal\twig_theme_test\TwigThemeTestController::activeThemeRender'
+  requirements:
+    _access: 'TRUE'
diff --git a/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php b/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php
index 3866965..2b16e56 100644
--- a/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php
+++ b/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php
@@ -32,7 +32,7 @@ public function testEscaping($template, $expected) {
       'autoescape' => TRUE,
       'optimizations' => 0
     ));
-    $twig->addExtension((new TwigExtension($renderer))->setGenerators($this->getMock('Drupal\Core\Routing\UrlGeneratorInterface')));
+    $twig->addExtension((new TwigExtension($renderer))->setUrlGenerator($this->getMock('Drupal\Core\Routing\UrlGeneratorInterface')));
 
     $nodes = $twig->parse($twig->tokenize($template));
 
