diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php
index c29b332..b547d95 100644
--- a/core/lib/Drupal/Core/Utility/LinkGenerator.php
+++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php
@@ -85,7 +85,7 @@ public function generateFromUrl($text, Url $url) {
     }
 
     // Set the "active" class if the 'set_active_class' option is not empty.
-    if (!empty($variables['options']['set_active_class'])) {
+    if (!empty($variables['options']['set_active_class']) && !$url->isExternal()) {
       // Add a "data-drupal-link-query" attribute to let the
       // drupal.active-link library know the query in a standardized manner.
       if (!empty($variables['options']['query'])) {
diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
index 55f4339..1d01b16 100644
--- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
@@ -121,7 +121,7 @@ public function testGenerateHrefs($route_name, array $parameters, $absolute, $ur
   }
 
   /**
-   * Tests the generateFromUrl() method.
+   * Tests the generateFromUrl() method with a route.
    *
    * @covers ::generateFromUrl()
    */
@@ -149,6 +149,38 @@ public function testGenerateFromUrl() {
   }
 
   /**
+   * Tests the generateFromUrl() method with an external URL.
+   *
+   * The set_active_class option is set to TRUE to ensure this does not cause
+   * an error together with an external URL.
+   *
+   * @covers ::generateFromUrl()
+   */
+  public function testGenerateFromUrlExternal() {
+    $this->urlGenerator->expects($this->once())
+      ->method('generateFromPath')
+      ->with('http://drupal.org', array('set_active_class' => TRUE) + $this->defaultOptions)
+      ->will($this->returnValue('http://drupal.org'));
+
+    $this->moduleHandler->expects($this->once())
+      ->method('alter')
+      ->with('link', $this->isType('array'));
+
+    $url = Url::createFromPath('http://drupal.org');
+    $url->setUrlGenerator($this->urlGenerator);
+    $url->setOption('set_active_class', TRUE);
+
+    $result = $this->linkGenerator->generateFromUrl('Drupal', $url);
+    $this->assertTag(array(
+      'tag' => 'a',
+      'attributes' => array(
+        'href' => 'http://drupal.org',
+      ),
+      'content' => 'Drupal',
+    ), $result);
+  }
+
+  /**
    * Tests the link method with additional attributes.
    *
    * @see \Drupal\Core\Utility\LinkGenerator::generate()
