In April 1685, he had shifted his residence to Paonta in Sirmur state. He was compelled to quit Anandpur owing to differences with Bhim Chand and went to Toka thereby. He was brought to Nahan and then proceeded to Paonta. He remained there for three years. After the Battle of Bhangani, Rani Champa, the dowager queen of Bilaspur requested the Guru to return to Chakk Nanaki to which he agreed. He then visited Raipur in Haryana and continued his journey to Anandpur, passing through Toda, Nada, Dhakoli, Kotla, Ghanaula, Bunga, and Kiratpur.
In 1695, Dilawar Khan, the Mughal chief of Punjab, sent his son with an army of one thousand men to Anandpur, to check the rising power of the Guru. As Khanzada crossed the Satluj River, Guru's scout Alam Chand (aka Alam Singh) alerted the Guru's forces. The Ranjit Nagara was beaten, and the Guru's men quickly marched to the river, forcing the Mughal army to retreat back.
After Hussain's death, Dilawar Khan sent his men Jujhar Hada and Chandel Rai to Sivalik Hills. However, they were defeated by Gaj Singh of Jaswal. The developments in the hill area caused anxiety to the Mughal emperor Aurangzeb, who sent forces under the command of his son; to restore Mughal authority in the region.The formation of the military order Khalsa did not go well with the Rajas of the Sivalik Hills, who in turn got united to evict the Guru from the region. However their expeditions during 1700-04 were unsuccessful.
Wazir Khan who was the Nawab of Sirhind was uncomfortable about any conciliation between Guru Gobind Singh and Bahadur Shah I. He had assigned the two pathans in order to kill him. They pursued him and got an opportunity to attack him at Nanded. Jamshed Khan stabbed the Guru in the left side below the heart while he was resting in his chamber after the prayer. The attacker was killed. The European surgeon was sent by Bahadur Shah to stitch the Guru's wound. The wound re-opened that caused profuse bleeding. Seeing his end the Guru declared the Granth Sahib as the next Guru of the Sikhs. It is believed that he breathed his last on 7 October 1708 at Nanded.