Under the Qing dynasty (1644–1911), the Nanjing area was known as Jiangning (江寧) and served as the seat of government for the Viceroy of Liangjiang. It had been visited by the Kangxi and Qianlong emperors a number of times on their tours of the southern provinces. Nanjing was invaded by British troops during the close of the First Opium War, which was ended by the Treaty of Nanjing in 1842. As the capital of the brief-lived rebel Taiping Heavenly Kingdom (founded by the Taiping rebels in the mid-19th century, Nanjing was known as Tianjing (天京, "Heavenly Capital" or "Capital of Heaven").