From the death of the tenth guru in 1708 until the British annexation of Punjab in 1849, the Sikhs maintained control over various parts of Punjab. At their height, the Sikhs established a kingdom which included Lahore, Amritsar, and various smaller Sikh confederacies.
Initiation into the Khalsa helped to unify the community for the trials that were soon to come. The remainder of Guru Gobind Singh’s reign was marked by fierce wars as the Sikh community defended itself against the repeated attacks of the local Hindu chiefs and the Mughal forces. In 1704, the Sikhs were forced to evacuate Anandpur. In the melee that followed, two of Guru Gobind Singh’s sons were killed. The other two were captured and tortured to death. But these tragedies did not destroy the spirit of the community.
In 1708 the guru was stabbed by assassins who had entered his camp as friends. He managed to kill one of them, and the other was killed by his guards. Although Guru Gobind Singh received treatment for his wounds, they were severe; some days later, while stringing his bow, the wounds opened again. The guru assembled his followers, installed the Guru Granth Sahib as guru, and bade farewell to the community.
Guru Gobind Singh did, however, outlive the Mughal Emperor Aurangzeb who died in 1707. At the time of Guru Gobind Singh’s death, he had sided with Bahadur Shah in the complex struggle for Mughal succession. In the disorder of these years, Banda Singh established an area of Sikh rule in parts of the Punjab. “Raj karega Khalsa!” (“The Khalsa shall rule!”) was the cry. The attempt was short-lived, lasting only from 1712 to 1716, but the groundwork was laid for the future. For much of the 18th century, the Sikhs were under threat and siege from both Afghans and Mughals, caught in the crossfire of wars and vengeance. From about the 1760s, however, Sikhs were the de facto rulers of many parts of the Punjab.
By the end of the 18th century, a leader named Ranjit Singh had assembled a force strong enough to gain power in the city of Lahore, which became the seat of a Sikh kingdom for 40 years. He extended his power to Amritsar in 1802, consolidating the various Sikh confederacies under his control. Ranjit Singh had consummate diplomatic skills and included Muslim and Hindu officers in his administration. After his death in 1839, the Sikh kingdom fell into disarray, and in 1849, the British Empire was able to annex the Punjab.