diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index dc2847d..8c864ea 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -1511,10 +1511,11 @@ function taxonomy_field_widget_form(&$form, &$form_state, $field, $instance, $la
     $tags[$item['tid']] = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']);
   }
 
+  $vocabulary_name = $field['settings']['allowed_values'][0]['vocabulary'];
   $element += array(
     '#type' => 'textfield',
     '#default_value' => taxonomy_implode_tags($tags),
-    '#autocomplete_path' => $instance['widget']['settings']['autocomplete_path'] . '/' . $field['field_name'],
+    '#autocomplete_path' => $instance['widget']['settings']['autocomplete_path'] . '/' . $vocabulary_name,
     '#size' => $instance['widget']['settings']['size'],
     '#maxlength' => 1024,
     '#element_validate' => array('taxonomy_autocomplete_validate'),
diff --git a/modules/taxonomy/taxonomy.pages.inc b/modules/taxonomy/taxonomy.pages.inc
index 3aed290..720b0fb 100644
--- a/modules/taxonomy/taxonomy.pages.inc
+++ b/modules/taxonomy/taxonomy.pages.inc
@@ -74,10 +74,34 @@ function taxonomy_term_feed($term) {
 }
 
 /**
- * Helper function for autocompletion
+ * Autocomplete callback function for taxonomy tags.
+ *
+ * @param $vocabulary_name
+ *  The machine name of the vocabulary to autocomplete on.
+ * @param $tags_typed
+ *  A comma-separated list of tags. We only autocomplete the last tag.
+ *
+ * @return
+ *   JSON list of matching tags.
  */
-function taxonomy_autocomplete($field_name, $tags_typed = '') {
-  $field = field_info_field($field_name);
+function taxonomy_autocomplete($vocabulary_name, $tags_typed = '') {
+  $term_matches = taxonomy_autocomplete_get_matches($vocabulary_name, $tags_typed);
+  drupal_json_output($term_matches);
+}
+
+/**
+ * Helper function to generate taxonomy autocomplete suggestions.
+ *
+ * @param $vocabulary_name
+ *  The machine name of the vocabulary to autocomplete on.
+ * @param $tags_typed
+ *  A comma-separated list of tags. We only autocomplete the last tag.
+ *
+ * @return
+ *  An associative array of possible matches, keyed by the corresponding
+ *  autocomplete field value (including other field values).
+ */
+function taxonomy_autocomplete_get_matches($vocabulary_name, $tags_typed = '') {
 
   // The user enters a comma-separated list of tags. We only autocomplete the last tag.
   $tags_typed = drupal_explode_tags($tags_typed);
@@ -86,12 +110,8 @@ function taxonomy_autocomplete($field_name, $tags_typed = '') {
   $matches = array();
   if ($tag_last != '') {
 
-    // Part of the criteria for the query come from the field's own settings.
-    $vids = array();
     $vocabularies = taxonomy_vocabulary_get_names();
-    foreach ($field['settings']['allowed_values'] as $tree) {
-      $vids[] = $vocabularies[$tree['vocabulary']]->vid;
-    }
+    $vid = $vocabularies[$vocabulary_name]->vid;
 
     $query = db_select('taxonomy_term_data', 't');
     $query->addTag('translatable');
@@ -104,7 +124,7 @@ function taxonomy_autocomplete($field_name, $tags_typed = '') {
     // Select rows that match by term name.
     $tags_return = $query
       ->fields('t', array('tid', 'name'))
-      ->condition('t.vid', $vids)
+      ->condition('t.vid', $vid)
       ->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE')
       ->range(0, 10)
       ->execute()
@@ -125,5 +145,5 @@ function taxonomy_autocomplete($field_name, $tags_typed = '') {
     }
   }
 
-  drupal_json_output($term_matches);
+  return $term_matches;
 }
diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 80ddc84..4b92a61 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -629,7 +629,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
 
     // Test autocomplete on term 2.
     $input = substr($term2->name, 0, 3);
-    $this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->machine_name . '/' . $input);
+    $this->drupalGet('taxonomy/autocomplete/' . $this->vocabulary->machine_name . '/' . $input);
     $this->assertRaw('{"' . $term2->name . '":"' . $term2->name . '"}', t('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term2->name)));
   }
 
