Yajna Narayan and Jagat Narayan (sons of Nazir Mahi) attacked Behar again with Bhutanese troops, captured the palace and massacred the royal family, including Basudev Narayan. The Raikats Yogyadev and Bhujdev intervened again, defeating Yajna Narayan in a battle on the banks of the Mansai river. The Raikats then crowned Mahendra Narayan (1682–1693), a five-year-old grandson of Pran Narayan, as the next Maharajah. During the minority rule of Mahendra Narayan, the state was unsettled. The lords of places such as Tepa, Manthana Kakina and Karjirhat rejected Bihari rule in place of direct tribute to the Mughal rulers as zamindars (landlords) of their territories. They accepted the authority of, and paid taxes to, Ibrahim Khan the Mughal Faujdar of Ghoraghat and Dhaka. Even the Raikat princes of Baikunthapur and Pangar transferred loyalty to these powers. The Mughals chose this time to attack Behar. With no other choice, Mahendra made a pact with Yajna Narayan and appointed him as Nazir. Aided by the Bhutanese, Yajna Narayan fought the Mughals at Patgram but was defeated. The Mughals took Boda, Patgram and eastern Pargana in the year 1711 and had gained near full control of North Bengal once again. Mahendra Narayan died at the age of 16. With the main royal line extinct, Rup Narayan (1693–1714), a grandson of Nazir Mahi Narayan, became the next Maharajah. Rup Narayan was a strong and popular ruler, but made the mistake of attacking the Mughal Faujdar of Rangpur. Defeated, he lost Karjihat, Kakina and Fatehpur Chakla, retaining only Boda, Patgram and eastern Chakla. Soon after, he lost these territories too, and was reduced to holding the three Chaklas under lease to the Mughals in the name of his Najir. He moved his capital from Atharokotha to a new site, Guriahati on the east bank of the Torsa River, where he built a beautiful temple of Sri Madan Mohan Thakur. Upendra Narayan (1714–1763), the next ruler, had no son of his own. He adopted Deena Narayan, the son of dewan Satya Narayan, and gave him considerable powers, but did not formally grant him the succession to the throne. Deena Narayan met the Mughal Faujdar Md. Ali Khan at Rangpur and agreed to accept Mughal supremacy in return for Md. Ali Khan's support in gaining the throne. Md. Ali Khan invaded, but was forced back by a combined army from Behar and Bhutan and had to flee to Rangpur.