During the Song Dynasty (AD 960–1279) Shanghai was upgraded in status from a village to a market town in 1074, and in 1172 a second sea wall was built to stabilize the ocean coastline, supplementing an earlier dyke. From the Yuan Dynasty in 1292 until Shanghai officially became a city in 1927, the area was designated merely as a county seat administered by the Songjiang prefecture.
Two important events helped promote Shanghai's development in the Ming Dynasty. A city wall was built for the first time in 1554 to protect the town from raids by Japanese pirates. It measured 10 metres high and 5 kilometres in circumference. During the Wanli reign (1573–1620), Shanghai received an important psychological boost from the erection of a City God Temple in 1602. This honour was usually reserved for places with the status of a city, such as a prefectural capital not normally given to a mere county town, as Shanghai was. It probably reflected the town's economic importance, as opposed to its low political status.
During the Qing Dynasty, Shanghai became one of the most important sea ports in the Yangtze Delta region as a result of two important central government policy changes: First, Emperor Kangxi (1662–1723) in 1684 reversed the previous Ming Dynasty prohibition on ocean going vessels – a ban that had been in force since 1525. Second, in 1732 Emperor Yongzheng moved the customs office for Jiangsu province (江海关; see Customs House, Shanghai) from the prefectural capital of Songjiang city to Shanghai, and gave Shanghai exclusive control over customs collections for Jiangsu Province's foreign trade. As a result of these two critical decisions, Professor Linda Cooke Johnson has concluded that by 1735 Shanghai had become the major trade port for all of the lower Yangtze River region, despite still being at the lowest administrative level in the political hierarchy.
A three dimensional diorama of the Bund as it would have appeared in the