Under the Qing, Zhenjiang was a city of half a million surrounded by a series of brick city walls up to high. It was captured by the British on 21 July 1842 during the First Opium War and after a fierce resistance, leaving the path open to Nanjing and prompting a concessionary treaty to avoid its loss. A decade later, massive floods of the Yellow River altered its course north of Shandong and closed the northern path of the Grand Canal. Soon after, the town was sacked by the Taiping rebels in 1853. It was recaptured by the Qing in 1858 and opened as a treaty port in 1861. Into the 1870s, Chaozhou merchants used their connections in Zhenjiang to make it a regional distribution center for opium purchased from the foreign merchants in Shanghai; when David Sassoon attempted to avoid taxation by delivering his cargoes directly to the opium merchants in Zhenjiang, the Chinese organized to intimidate his customers and then bought out his failed organization. The population was estimated at 168,000 in 1904.