diff --git a/search_api.module b/search_api.module
index 0890fca..dd3eb83 100644
--- a/search_api.module
+++ b/search_api.module
@@ -3323,3 +3323,36 @@ function _search_api_batch_indexing_finished($success, $results) {
   }
 
 }
+
+/**
+ * Implements hook_form_FORM_API_alter() for form_views_exposed_form_alter().
+ *
+ * Custom integration for FacetAPI. When a Views exposed filter is modified
+ * on a search results page it will loose any facets which have been already
+ * selected. This adds hidden fields for each facet so their values are
+ * retained.
+ */
+function search_api_form_views_exposed_form_alter(&$form, &$form_state) {
+  // Check if this form is a Search API form. This could be replaced with the
+  // value of a custom Views setting like e.g. "Include facets".
+  if (isset($form_state['view']) && $form_state['view']->base_field === 'search_api_id') {
+    // Only proceed if FacetAPI is installed.
+    if (module_exists('facetapi')) {
+      // Get quary parameters.
+      $query_parameters = drupal_get_query_parameters();
+
+      // If any facet query parameters are provided.
+      if (!empty($query_parameters['f'])) {
+        // Iterate through facet query parameters.
+        foreach ($query_parameters['f'] as $key => $value) {
+          // Add hidden form field for facet parameter.
+          $form['f[' . $key . ']'] = array(
+            '#type' => 'hidden',
+            '#value' => $value,
+            '#weight' => -1,
+          );
+        }
+      }
+    }
+  }
+}
