Lahore's origins reach into antiquity. The city has been controlled by numerous empires throughout the course of its history, including the Hindu Shahis, Ghaznavids, Ghurids, and Delhi Sultanate by the medieval era. Lahore reached the height of its splendour under the Mughal Empire between the late 16th and early 18th century, and served as its capital city for a number of years. The city was captured by the forces of the Afsharid ruler Nader Shah in 1739, and fell into a period of decay while being contested between the Afghans and the Sikhs. Lahore eventually became capital of the Sikh Empire in the early 19th century, and regained much of its lost grandeur. Lahore was then annexed to the British Empire, and made capital of British Punjab. Lahore was central to the independence movements of both India and Pakistan, with the city being the site of both the declaration of Indian Independence, and the resolution calling for the establishment of Pakistan. Lahore experienced some of the worst rioting during the Partition period preceding Pakistan's independence. Following independence in 1947, Lahore was declared capital of Pakistan's Punjab province.