The Battle of Anandpur was fought at Anandpur , between Sikhs and an allied force of the Rajas of the Sivalik Hills.
The hill Rajas were concerned about Guru Gobind Singh's rising power and influence in their region. Even the Mughal generals had failed to subdue the Guru in the First Battle of Anandpur. Consequently, the Rajas of several hill states (including Jammu, Nurpur, Mandi, Kullu, Guler, Chamba, Srinagar, Dadhwal, and Hindur) assembled at Bilaspur to discuss the situation. The son of Bhim Chand, Raja Ajmer Chand of Kahlur, suggested forming an alliance to curb the Guru's rising power. Accordingly, the Rajas formed an alliance, and marched towards Anandpur.
They sent a letter to the Guru, asking him to pay the arrears of rent for Anandpur (which lied in Ajmer Chand's territory), and leave the city. The Guru insisted that the land was bought by his father, and is therefore, his own property.
A large number of Ranghars and Gujjars, under the command of Jagatullah, joined the hill Rajas. Duni Chand led five hundred men from Majha region to assist the Guru. Reinforcements from other areas also arrived to help the Guru.
Lohgarh and Fatehgarh were the two main forts under Gobind Singh's control. Sher Singh and Nahar Singh were asked to guard Lohgarh, and Ude Singh was appointed as chief to guard Fatehgarh.
The hill Rajas attacked the Guru's forces, but had to retreat. They held a brief council, and decided to launch a three-sided attack. Raja Kesari Chand of Jaswal launched an attack from the right flank, Jagatullah attacked from the left flank, and Ajmer Chand led his troops to make a front attack on Anandpur.
In the ensuing battle, Jagatullah was killed by Bhai Sahib Singh. Raja Ghumand Chand of Kangra rallied his troops but failed to defeat the Guru's forces. The Rajas again held a council, in which Ajmer Chand proposed reconciliation with the Guru. Many Rajas agreed, but Raja Kesari Chand of Jaswal opposed the proposal, and suggested a more determined fight next day, to oust the Guru from Anandpur.
Next day, the Rajas' forces launched another attack and sieged the city. The Guru's men defended themselves successfully for weeks. Raja Kesari Chand then decided to send an intoxicated elephant to break the gate of Lohgarh fort. The body of the elephant was encased in steel, and a spear was projected from its forehead to break the gate. Guru's disciple, Vicihitar Singh (or Bachittar Singh) successfully chased away the elephant with his spear Nagni barchha. Bhai Mohkam Singh cut its trunk with his sword. The wounded elephant went back in the Rajas' camp, trampling several men under its feet. Meanwhile, Kesari Chand was killed by Ude Singh, and the Raja of Handur was severely wounded in a conflict with Bhai Sahib Singh. The Rajas' army had to retreat.
On the following day, the troops of Ghumand Chand of Kangra attacked Anandpur. The battle lasted till evening, and resulted in death of Ghumand Chand at the hands of Bhai Himmat Singh.
Sometime after the battle, the hill Rajas negotiated a peace agreement with Gobind Singh, asking him to leave Anandpur temporarily. Accordingly, the Guru left for Nirmoh village (Nirmohgarh).