Along with its commercial activities, Qinglong Zhen became a military and naval base and by the early 12th century a Superintendent of Foreign Trade was established in the settlement to supervise trade and tax collections across five counties. As a result, the flourishing and prosperous town earn the sobriquet "Little Hangzhou." According to official government sources, Shanghai first became a city in 1291 during the Yuan dynasty (1271–1368). At this time, five of Huating Zhen's villages were amalgamated to form a new Shanghai County () on the site of the modern city centre. This new settlement had a population of about 300,000 with many engaged in the shipping trade. Ming dynasty By the early 15th century, Shanghai had become important enough for Ming dynasty engineers to begin dredging the Huangpu River (also known as Shen). In 1553, a city wall was built around the Old Town (Nanshi) as a defense against the depredations of the Wokou (Japanese pirates). Shanghai had its first contact with the Jesuits in 1603 when the Shanghai scholar-bureaucrat Xu Guangqi was baptized by Jesuit priest Matteo Ricci. Xu later bequeathed some of his land in Shanghai, today's Xujiahui, meaning Xu family village, to the Catholic Church. By the end of the Ming dynasty in 1644, Shanghai had become a major cotton and textile center with a population that would soon reach 200,000. Qing dynasty During the late Qing dynasty, Shanghai's economy began to rival that of the traditionally larger market at Suzhou. In the 18th and early 19th centuries, exports of cotton, silk, and fertilizer reached as far as Polynesia and Persia. In 1832, the East India Company explored Shanghai and the Yangzi River as a potential trading center for tea, silk, and opium, but were rebuffed by local officials. Chinese attempts to prohibit the opium trade into China led to the First Opium War (1839-1842) with the United Kingdom; the Treaty of Nanjing, which concluded the war with a British victory, opened up five treaty ports in China to British merchants, including Shanghai. Similar treaties were quickly signed with other Western nations, and French, American and German merchants joined their British counterparts in establishing a presence in Shanghai, residing in sovereign concessions where they were not subject to Chinese laws. The British established their concession in 1845, the Americans in 1848 in Hongkou, north of Suzhou Creek, and the French set up their concession in