Maharaja Ranjit Singh (13 November 1780 – 27 June 1839) became the first ruler of the Sikh Empire after gaining independence from the Afghan Empire. He began as a young warrior, who was later chosen by Zaman Shah Durrani to serve as the governor of Punjab. He then assembled his Sikh army and began war with the Afghans, ending their rule in Punjab and driving them toward Peshawar. Ranjt Singh was succeeded by his son, Kharak Singh.
Ranjit Singh belonged to a Sikh clan of Northern India. He was born in Gujranwala, a city now in modern-day Pakistan. According to some historians, he was born into a Jatt Sikh family while others claim that he was born into a Sansi Sikh family of Sukerchakia Misldars. As a child he suffered from smallpox which resulted in the loss of one eye. At the time, much of the Punjab region was ruled by the Afghan Empire of Ahmad Shah Durrani under a confederate Sarbat Khalsa system, who had divided the territory among factions known as misls.
Ranjit Singh's father Maha Singh was the Commander of the Sukerchakia misl and controlled a territory in western Punjab, based around his headquarters at Gujranwala. After his father's death he was raised under the protection of Sada Kaur of the Kanheya Misl. Ranjit Singh succeeded his father at the age of 18.
Amir Ahmad Shah Durrani of Afghanistan first crossed the Indus River in 1738, during Nader Shah's invasion of the Mughal Empire. The second time Durrani crossed the Indus River was in 1748, the year after his ascension – his forces sacked and absorbed Lahore during that expedition. The following year, in 1749, the Mughal ruler was induced to cede Sindh and all of the Punjab region including the vital trans Indus River to Ahmad Shah, in order to save his capital from being attacked by the Afghan forces of the Durrani Empire.
In 1756-57, in what was his fourth invasion of India, Ahmad Shah sacked Delhi, Agra, Mathura, and Vrndavana. However, he did not displace the Muslim Mughal dynasty, which remained in nominal control as long as the ruler acknowledged Ahmad Shah's suzerainty over the Punjab region, Sindh, and Kashmir.
Durrani installed Alamgir II, on the Mughal throne, and arranged marriages for himself and his son Timur Shah into the imperial family that same year. Durrani married the daughter of Mughal Emperor, Muhammad Shah. Leaving his second son Timur Shah (who was arrainged for marriage to the daughter of Alamgir II) to safeguard his interests. The Sikhs were becoming too troublesome for the Durranis, and after several unsuccessful efforts to subdue them, Zaman Shah Durrani made the mistake of appointing the forceful young Sikh chief, Ranjit Singh, as his governor in the Punjab. The "one-eyed" warrior would later become an implacable enemy of the Durrani Pashtun rulers.
About 30 years before Ranjit Singh became the governor of Punjab, Lahore and its environs were ruled by a triumvirate of Sikhs which included Lehna Singh Majithia as a mayor of the city. The rule of these three Sikh chieftains started when the Durranis at Kabul decided to give Lahore to Sardar Majithia. In 1765, Majithia teamed up with two other Sikh chieftains to secure the environs around Lahore, which is how the triumvirate of Majithia, Gujjar Singh Banghi and Suba Singh came to occupy power in and around Lahore.
For thirty long years, Majithia, Banghi and Suba Singh ruled supreme but were paying the Durranis an annual sum as taxes. The Lahore Fort, the walled city of Lahore, and its gates went to Majithia. To Suba Singh was rewarded the area to the south of the walled city of Lahore, he resided in the garden of Zubaida Begum in Nawankot, where he built a small fort for himself.
The area between Amritsar and Lahore, or more correctly between the Shalamar Gardens and Lahore, was given to Banghi. The land was a jungel but Banghi erected that part of the city and invited people to settle. He also dug wells to supply water. A mosque was also built for the Muslims in the area. He also built himself a small fort called Qila Gujar Singh. Today, a few walls of this old fort can be seen in a street between Nicholson Road and Empress Road, and the area is still called Qila Gujar Singh. Their rule ended after Ranjit Singh besieged the Lahore Fort in 1799, and Majithia, Singh Banghi and Suba Singh fled, leaving the city firmly in the hands of Ranjit's army. Lehna Singh Majithia was later made Ranjit Singh's most able ministers and advisers and a General in Ranjit's army. Ranjit was also acclaimed as the bravest soldier of Punjab.