Within China, the city ranked second in urban population after Shanghai and the third in municipal population after Shanghai and Chongqing. Beijing also ranks among the most populous cities in the world, a distinction the city has held for much of the past 800 years, especially during the 15th to early 19th centuries when it was the largest city in the world.