diff --git a/pathauto.module b/pathauto.module
index 4c794a5..d4f5b2a 100644
--- a/pathauto.module
+++ b/pathauto.module
@@ -227,6 +227,20 @@ function pathauto_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
          */
         $node->path = $node->old_alias;
       }
+      // Special case when we do not go through the form API, but directly via node_save
+      if (empty($node->pathauto_perform_alias) && !isset($node->pathauto_form) && isset($node->path) && isset($node->nid)) {
+        // If this is not a new node, compare it's current alias to the
+        // alias that would be genereted by pathauto. If they are the same,
+        // then keep the automatic alias enabled.
+
+        // We need to load old node for this to work, but it should be still cached anyway ...
+        $old_node = node_load($node->nid);
+
+        _pathauto_include();
+        $placeholders = pathauto_get_placeholders('node', $old_node);
+        $pathauto_alias = pathauto_create_alias('node', 'return', $placeholders, "node/{$old_node->nid}", $old_node->nid, $old_node->type, $old_node->language);
+        $node->pathauto_perform_alias = isset($old_node->path) && $old_node->path == $pathauto_alias;
+      }
       break;
     case 'insert':
     case 'update':
@@ -332,6 +346,10 @@ function pathauto_form_alter(&$form, $form_state, $form_id) {
           '#value' => $node->path,
         );
       }
+      $form['path']['pathauto_form'] = array(
+          '#type' => 'value',
+          '#value' => TRUE,
+      );
     }
   }
 }
diff --git a/pathauto.test b/pathauto.test
index 3fbd012..7d21d61 100644
--- a/pathauto.test
+++ b/pathauto.test
@@ -413,6 +413,75 @@ class PathautoFunctionalTestCase extends PathautoFunctionalTestHelper {
     $this->assertResponse(404, 'Node not accessible through automatic alias.');
     $this->drupalGet($manual_alias);
     $this->assertText($title, 'Node accessible through manual alias.');
+
+    // 1. Test that node_save is working like drupalPost
+    //   old alias = "manual-alias"
+    //   auto alias = "content/simpletest-title-*"
+    //   resulting alias == "manual-alias"
+
+    // Manually set the node's alias.
+    $manual_alias = 'content/' . $node->nid;
+    $edit = array(
+      'pathauto_perform_alias' => FALSE,
+      'path' => $manual_alias,
+    );
+    $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+
+    $test_node = node_load($node->nid, NULL, TRUE);
+    node_save($test_node);
+
+    $this->drupalGet($automatic_alias);
+    $this->assertResponse(404, 'Node not accessible through automatic alias.');
+    $this->drupalGet($manual_alias);
+    $this->assertText($title, 'Node accessible through manual alias.');
+
+    // 2. Test that node_save is working like drupalPost
+    //   old alias = "manual-alias"
+    //   auto alias = "content/simpletest-title-*"
+    //   pathauto_perform_alias = 1
+    //   resulting alias = "content/simpletest-title-*"
+
+    // Manually set the node's alias.
+    $manual_alias = 'content/' . $node->nid;
+    $edit = array(
+      'pathauto_perform_alias' => FALSE,
+      'path' => $manual_alias,
+    );
+    $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+
+    $test_node = node_load($node->nid, NULL, TRUE);
+    $test_node->pathauto_perform_alias = TRUE;
+    node_save($test_node);
+
+    $this->drupalGet($automatic_alias);
+    $this->assertText($title, 'Node accessible through automatic alias.');
+    $this->drupalGet($manual_alias);
+    $this->assertResponse(404, 'Node not accessible through manual alias.');
+
+    // 3. Test that node_save is working like drupalPost
+    //   old alias = "content/simpletest-title-*"
+    //   old title = "simpletest title *"
+    //   new title = "simpletest new title *"
+    //   auto alias = "content/simpletest-new-title-*"
+    //   resulting alias == "content/simpletest-new-title-*"
+
+    $edit = array(
+      'pathauto_perform_alias' => TRUE,
+      'path' => '',
+    );
+    $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+
+    $test_title = ' Simpletest new title ' . $random_title . ' [';
+    $test_automatic_alias = 'content/simpletest-new-title-' . strtolower($random_title);
+
+    $test_node = node_load($node->nid, NULL, TRUE);
+    $test_node->title = $test_title;
+    node_save($test_node);
+
+    $this->drupalGet($test_automatic_alias);
+    $this->assertText($test_title, 'Node accessible through new automatic alias.');
+    $this->drupalGet($automatic_alias);
+    $this->assertResponse(404, 'Node not accessible through automatic alias.');
   }
 
   /**
