forces agreed to leave Delhi and reinstate the Mughal emperor Shah Alam II. The condition of their retreat included the construction of seven Sikh Gurdwaras in Delhi, including the Gurudwara Sis Ganj in Chandni Chowk. In 1788, a Maratha garrison occupied the Red Fort and Delhi alongside providing protection to the Mughal Emperor. Mahadji Scindia signed a treaty with the Sikhs where they were warned not to enter Delhi or ask for the Rakhi tribute. The fort came under the control of the East India Company following the Second Anglo-Maratha War in 1803. During the Second Anglo-Maratha War, forces of the East India Company defeated Maratha forces of Daulat Rao Scindia in the Battle of Delhi; this ended Maratha control over the city and their control of the Red Fort. After the battle, the British East India Company took over the administration of Mughal territories and installed a Resident at the Red Fort. The last Mughal emperor to occupy the fort, Bahadur Shah II, became a symbol of the 1857 rebellion against the British East India Company in which the residents of Shahjahanabad participated. Despite its position as the seat of Mughal power and its defensive capabilities, the Red Fort was not a site of an engagement during the 1857 uprising against the British. After the rebellion was defeated, Bahadur Shah II left the fort on 17 September and was apprehended by British forces. Bahadur Shah Zafar II returned to Red Fort as a British prisoner, was tried in 1858 and exiled to Rangoon on 7 October of that year. After the end of the rebellion, the British sacked the Red Fort before ordering its systemic demolition. 80% of the fort’s buildings were demolished as a result of this effort, including the stone screen that connected the pavilions along the fort’s river-facing façade, which was demolished. All furniture was removed or destroyed; the harem apartments, servants' quarters and gardens were demolished, and a line of stone barracks built in their place. Only the marble buildings on the east side at the imperial enclosure escaped complete destruction, although they were damaged by the demolition efforts. While the defensive walls and towers were relatively unharmed, more than two-thirds of the inner structures were demolished. Lord Curzon, Viceroy of India from 1899 to 1905, ordered repairs to the fort including reconstruction of the walls and the restoration of the gardens complete with a