diff --git a/core/includes/common.inc b/core/includes/common.inc
index 6800fa5..f31a9d7 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -2298,13 +2298,20 @@ function l($text, $path, array $options = array()) {
   // Merge in defaults.
   $options += array(
     'attributes' => array(),
+    'query' => array(),
     'html' => FALSE,
   );
 
   // Append active class.
   if (($path == current_path() || ($path == '<front>' && drupal_is_front_page())) &&
       (empty($options['language']) || $options['language']->langcode == language(LANGUAGE_TYPE_URL)->langcode)) {
-    $options['attributes']['class'][] = 'active';
+    // Only mark the link as active, if the query parameters of the current
+    // request equal the query parameters of the link, since the same request
+    // with different query parameters may yield a completely different page
+    // (e.g., pagers).
+    if (drupal_container()->get('request')->query->all() == $options['query']) {
+      $options['attributes']['class'][] = 'active';
+    }
   }
 
   // Remove all HTML and PHP tags from a tooltip. For best performance, we act only
diff --git a/core/includes/pager.inc b/core/includes/pager.inc
index 91532e3..36be9ad 100644
--- a/core/includes/pager.inc
+++ b/core/includes/pager.inc
@@ -377,13 +377,7 @@ function theme_pager_link($variables) {
     }
   }
 
-  // @todo l() cannot be used here, since it adds an 'active' class based on the
-  //   path only (which is always the current path for pager links). Apparently,
-  //   none of the pager links is active at any time - but it should still be
-  //   possible to use l() here.
-  // @see http://drupal.org/node/1410574
-  $attributes['href'] = url(current_path(), array('query' => $query));
-  return '<a' . new Attribute($attributes) . '>' . check_plain($text) . '</a>';
+  return l($text, current_path(), array('query' => $query, 'attributes' => $attributes));
 }
 
 /**
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
index 39ed2b4..eeb49cc 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
@@ -16,6 +16,9 @@
  * inheriting from a web test case rather than a unit test case.
  */
 class UrlTest extends WebTestBase {
+
+  public static $modules = array('common_test');
+
   public static function getInfo() {
     return array(
       'name' => 'URL generation tests',
@@ -35,12 +38,28 @@ function testLXSS() {
     $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, format_string('XSS attack @path was filtered', array('@path' => $path)));
   }
 
-  /*
+  /**
    * Tests for active class in l() function.
    */
   function testLActiveClass() {
-    $link = l($this->randomName(), current_path());
-    $this->assertTrue($this->hasClass($link, 'active'), format_string('Class @class is present on link to the current page', array('@class' => 'active')));
+    $path = 'common-test/l-active-class';
+    $options = array();
+
+    $this->drupalGet($path, $options);
+    $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => url($path, $options), ':class' => 'active'));
+    $this->assertTrue(isset($links[0]), 'A link to the current page is marked active.');
+
+    $options = array('query' => array('foo' => 'bar'));
+    $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', array(':href' => url($path, $options), ':class' => 'active'));
+    $this->assertTrue(isset($links[0]), 'A link to the current page with a query string when the current page has no query string is not marked active.');
+
+    $this->drupalGet($path, $options);
+    $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => url($path, $options), ':class' => 'active'));
+    $this->assertTrue(isset($links[0]), 'A link to the current page with a query string that matches the current query string is marked active.');
+
+    $options = array();
+    $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', array(':href' => url($path, $options), ':class' => 'active'));
+    $this->assertTrue(isset($links[0]), 'A link to the current page without a query string when the current page has a query string is not marked active.');
   }
 
   /**
@@ -50,7 +69,6 @@ function testLCustomClass() {
     $class = $this->randomName();
     $link = l($this->randomName(), current_path(), array('attributes' => array('class' => array($class))));
     $this->assertTrue($this->hasClass($link, $class), format_string('Custom class @class is present on link when requested', array('@class' => $class)));
-    $this->assertTrue($this->hasClass($link, 'active'), format_string('Class @class is present on link to the current page', array('@class' => 'active')));
   }
 
   /**
diff --git a/core/modules/system/tests/modules/common_test/common_test.module b/core/modules/system/tests/modules/common_test/common_test.module
index 0634e3b..23b3622 100644
--- a/core/modules/system/tests/modules/common_test/common_test.module
+++ b/core/modules/system/tests/modules/common_test/common_test.module
@@ -58,6 +58,12 @@ function common_test_menu() {
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
+  $items['common-test/l-active-class'] = array(
+    'title' => 'Test l() adding of active class',
+    'page callback' => 'common_test_l_active_class',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
   return $items;
 }
 
@@ -296,3 +302,26 @@ function common_test_js_and_css_querystring() {
 function common_test_cron() {
   throw new Exception(t('Uncaught exception'));
 }
+
+/**
+ * Page callback: Displays links to the current page, one with a query string.
+ */
+function common_test_l_active_class() {
+  return array(
+    'no_query' => array(
+      '#type' => 'link',
+      '#title' => t('Link with no query string'),
+      '#href' => current_path(),
+    ),
+    'with_query' => array(
+      '#type' => 'link',
+      '#title' => t('Link with a query string'),
+      '#href' => current_path(),
+      '#options' => array(
+        'query' => array(
+          'foo' => 'bar',
+        ),
+      ),
+    ),
+  );
+}
