Factionalism inside the royal family led to a period of instability. In 1846, a plot was discovered revealing that the reigning queen had planned to overthrow Jung Bahadur Kunwar, a fast-rising military leader. This led to the Kot massacre; armed clashes between military personnel and administrators loyal to the queen led to the execution of several hundred princes and chieftains around the country. Bir Narsingh Kunwar emerged victoriously and founded the Rana dynasty, and came to be known as Jung Bahadur Rana. The king was made a titular figure, and the post of Prime Minister was made powerful and hereditary. The Ranas were staunchly pro-British and assisted them during the Indian Rebellion of 1857 (and later in both World Wars). In 1860 some parts of the western Terai region were gifted to Nepal by the British as a friendly gesture because of her military help to sustain British control in India during the rebellion (known as "Naya Muluk", new country). In 1923, the United Kingdom and Nepal formally signed an agreement of friendship that superseded the Sugauli Treaty of 1816.