Sikh period in Lahore
The Sikh Rule in Lahore initiated from the invasion and rule of the Sikh Misls and extended till the Sikh Empire of Ranjit Singh (also known as Punjab, the Sikh Raj, and Sarkar Khālsā Rāj) which ended in 1849. The Sikhs began gaining power following the decline of the Mughal Empire in Punjab and consisted of a collection of autonomous Punjabi Misls, which were governed by Misldars, mainly in the Punjab region.
Rebellion against the Mughal Empire
Early in Aurangzeb's reign, various insurgent groups of Sikhs engaged Mughal troops in increasingly bloody battles. In 1670, the ninth Sikh Guru, Guru Tegh Bahadur encamped in Delhi, receiving large numbers of followers, was said to have attracted the wrath of Emperor Aurangzeb.
The execution of Guru Tegh Bahadur infuriated the Sikhs. In response, his son and successor, the tenth Guru of Sikhism Guru Gobind Singh further militarized his followers.
The Khalsa, or the Sikh Army, were the first in history to abolish the Muslim states and Mughal Empire in the whole province of Punjab in one stroke. The Singhs (Lions), led by Banda Singh Bahadur took over many Muslim and Mughal lands, establishing a Sikh Empire.
Other existing Muslim Emperors proclaimed a war against the Banda and the Khalsa. However many Muslim armies and their Emperors fled in dismay and despair after Wazir Khan's head was stuck up on a spear and lifted high up by a Sikh who took his seat at Sirhind, Muslim troops on beholding the head took alarm.
In a temporary alliance, both groups consisting of Hindu Rajas and Muslim Governors attacked Guru Gobind Singh and his followers. The united Mughal-Rajput Imperial alliance laid siege to the fort at Anandpur Sahib. In an attempt to dislodge the Sikhs, Aurangzeb promised that the Guru and his Sikhs would be allowed to leave Anandpur safely. He is said to have validated this promise in writing. However, he deliberately failed to keep his promise and when the remaining few Sikhs were leaving the fort under the cover of darkness, the Mughals were alerted and engaged them in battle once again. Two of the younger sons of Guru Gobind Singh, Zoravar Singh and Fateh Singh, were bricked up alive within a wall by Wazir Khan in Sirhind (Punjab). The other two elder sons - Ajit Singh and Jujhar Singh along with several Sikhs fought against the giant Mughal force, achieving martyrdom. The Emperor died shortly after on 20 February 1707. He was succeeded by Bahādur Shāh, who invited the Gurū to a meeting which took place at Āgrā on 23 July 1707.
Nawāb Wazīr Khān of Sirhind objected to the Emperor's conciliatory treatment of the Guru and sent two of his soldiers, Jamshed Khan and Wāsil Beg, to kill the Guru. Jamshed Khan attacked and wounded the Guru, while he was sleeping, and was beheaded by one sword cut from the waking Guru. The Guru later died from the wounds inflicted on him. 
The Three Chieftains of the Sikh Misls
At the time of the late 18th century, frequent invasions by Ahmad Shah Abdali and the Durrani Empire led to a lack of governance in the Punjab region. During thirty years following the final departure of Ahmed Shah Abdali, the Sikhs were left to themselves and increased in wealth and numbers. They gradually divided themselves into independent misls, under the command of hereditary chieftains, having a common place of meeting at Amritsar. Lahore, meanwhile, was portioned out amongst a triumvirate of Sikh chieftains of the Bhangi Misl, named, respectively, Gujjar Singh, Lehna Singh and Sobha Singh, who are spoken of to this day as the Three Hakims. The three chieftains split the city's revenue. For almost thirty long years Gujjar Singh along with Lehna Singh and Sobha Singh, ruled supreme and kept paying the Afghan invader and his offspring an annual sum to keep them at bay.
The Lahore Fort and the Walled City and its gates went to Lehna Singh. He was, for formal purposes, the governor of Lahore, and was so recognized. To Suba Singh went the area to the south of the Walled City, and 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, went to Gujjar Singh. Gujjar Singh erected that part of the city, then a jungle and invited people to settle there. 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 that old fort can be seen in a street between today’s Nicholson Road and Empress Road, and the area is still called Qila Gujjar Singh.
The Bhangi misl engaged in numerous power struggles with the Sukerchakia Misl until they were severely weakened at the Battle of Basin when Ranjit Singh besieged the Lahore Fort in 1799. The three chieftains fled from the city and on 7 July 1799, Ranjit Singh became the master of Lahore. 
Ranjit Singh's Empire
Ranjit Singh was crowned on 12 April 1801 (to coincide with Baisakhi) as the leader of a Sikh misl. Sahib Singh Bedi, a descendant of Guru Nanak Dev, conducted the coronation. The 1740s were years of chaos, and the city had nine different governors between 1745 and 1756. Invasions and chaos in local government allowed bands of warring Sikhs to gain control in some areas. In 1799, all Sikh Misls (warring bands) joined into one to form a sovereign Sikh state ruled by Maharaja Ranjit Singh from the royal capital, Lahore. During the 1740s, frequent invasions by Afghans led by Ahmad Shah Abdali and chaos in local government had made life very uncomfortable for the citizens of Lahore. Bhangi Misl was the fist Sikh band to plunder the Mughal Lahore. Later Ranjit Singh was able to make gains in this chaos. He defeated Zaman Shah, the son of Abdali, in a battle between Lahore and Amritsar. Out of the chaos of Afghani and Sikh conflicts emerged a victorious Sikh by the name of Ranjit Singh who was able to unify the Sikh factions and capture Lahore where he was crowned Emperor.
Ranjit Singh made Lahore his capital (shifting from the former capital, Gujranwala) in 1799 and was able to expand the kingdom to the Khyber Pass and also included Jammu and Kashmir, while keeping the British from expanding across the River Sutlej for more than 40 years. He rose to power in a very short period, from a leader of a single Sikh misl to finally becoming the Maharaja (Emperor) of Punjab.
For a brief half century, from 1799 to 1846, Lahore recovered under the patronage of Ranjit Singh and his successors. Ranjit Singh consolidated the Sikh misldaars (commanders) who had ruled more or less independently during the eighteenth century under a unified command and in 1799 he established Lahore as the administrative capital of a new Sikh kingdom. Nearby Amritsar became the spiritual and commercial center of the kingdom in 1802, after Ranjit Singh's troops occupied the city and the maharaja announced his intention to extend patronage and protection to the city's leading groups.
While much of Lahore's Mughal era fabric lay in ruins by the end of eighteenth century, rebuilding efforts under the Sikhs were shaped by and indebted to Mughal practice. Ranjit Singh moved into the Mughal palace in Lahore's citadel. By 1812 he had mostly refurbished the city's defenses by adding a second circuit of outer walls that followed the outline of Akbar's original walls and were separated from them by a moat. The maharaja also partially restored Shah Jahan's decaying gardens at Shalimar, and British maps of the area surrounding Lahore dating from the mid-nineteenth century show that walled private gardens - many of them bearing the names of prominent Sikh nobles - continued in the Mughal pattern under Sikh rule. The Sikh court continued to endow religious architecture in the city, including a number of Sikh gurdwaras, Hindu temples, and mosques. In short, the decaying structures and architecture of Lahore was restored by the emperor.
Arrival of the British Colonial Rule
The British occupation of Lahore took place in a protracted but concerted manner. Capitalizing on the disarray surrounding the succession struggles after Ranjit Singh's death and only partially diminished by a war fought against the Sikhs on their eastern frontier, the British rode into Lahore in February 1846 and garrisoned their troops in the citadel. Two unstable years later, they were drawn into a second war with the Sikhs at the southern city of Multan when that city's governor, Diwan Mulraj Singh, encouraged his troops to rebel. After a series of closely fought battles, the Sikh army was finally defeated in the Battle of Gujrat, sixty miles north of Lahore. In March 1848, following the British victory, Dalip Singh, Ranjit Singh's teenage son and heir to the throne, was formally deposed in Lahore. The remaining Sikh regiments in the city were abruptly decommissioned and camped outside the city demanding severance pay. Within a year, the Punjab was formally annexed to the British Empire and military sappers had begun leveling Lahore's city wall.
- Nalwa, V. (2009), Hari Singh Nalwa - Champion of Khalsaji, New Delhi: Manohar, p. 10, ISBN 81-7304-785-5.
- Grewal, J. S. (1990). "Chapter 6: The Sikh empire (1799–1849)". The Sikh empire (1799–1849). The New Cambridge History of India. The Sikhs of the Punjab. Cambridge University Press.
- Encyclopædia Britannica Eleventh Edition, (Edition: Volume V22, Date: 1910-1911), Page 892.
- The Ninth Master Guru Tegh Bahadur (1621-1675)
- J. S. Grewal (1998). The Sikhs of the Punjab. Cambridge University Press. p. 79. ISBN 0521637643.
- Ganda Singh. "GOBIND SIṄGH, GURŪ (1666-1708)". Encyclopaedia of Sikhism. Punjabi University Patiala.
- Sykes, Percy (2008)A History of Persia READ books. ISBN 9781443724081
- Cave-Browne 1861, p. 368
- Singh, Khushwant A History of the Sikhs, Volume 1: 1469-1839. Oxford University Press, 2004, Page 198, Footnote 11
- "Ranjit Singh, Maharaja", Sikh Cyber Museum