The first fortified settlements on the site of today's Warsaw are dated to 9th/10th century) and Jazdów (12th/13th century). The Prince of Płock, Bolesław II of Masovia, established a settlement, the modern-day Warsaw, in about 1300. 14th-century Warsaw's economy rested on mostly crafts and trade. The duchy was reincorporated into the Crown of the Kingdom of Poland in 1526.
In 1573 the city gave its name to the Warsaw Confederation, formally establishing religious freedom in the Polish–Lithuanian Commonwealth. Due to its central location between the Commonwealth's capitals of Kraków and Vilnius, Warsaw became the capital of the Commonwealth and the Crown of the Kingdom of Poland when King Sigismund III Vasa moved his court from Kraków to Warsaw in 1596. Three times between 1655–1658 the city was under siege and three times it was taken and pillaged by the Swedish, Brandenburgian and Transylvanian forces.
Warsaw remained the capital of the Polish–Lithuanian Commonwealth until 1796, when it was annexed by the Kingdom of Prussia to become the capital of the province of South Prussia. Liberated by Napoleon's army in 1806, Warsaw was made the capital of the newly created Duchy of Warsaw. Following the Congress of Vienna of 1815, Warsaw became the centre of the Congress Poland, a constitutional monarchy under a personal union with Imperial Russia.
Warsaw flourished in the late 19th century, city saw its first water and sewer systems designed and built, as well as the expansion and modernisation of trams, street lighting and gas works.
The Russian Empire Census of 1897 recorded 626,000 people living in Warsaw, making it the third-largest city of the Empire after St. Petersburg and Moscow.
After the German Invasion of Poland on 1 September 1939 began the Second World War. All higher education institutions were immediately closed and Warsaw's entire Jewish population – several hundred thousand, some 30% of the city – herded into the Warsaw Ghetto. The city would become the centre of urban resistance to Nazi rule in occupied Europe.
The Warsaw Uprising took place in 1944. The Polish Home Army attempted to liberate Warsaw from German occupation before the arrival of the Red Army. The Germans then razed Warsaw to the ground. Hitler, ignoring the agreed terms of the capitulation, ordered the entire city to be razed to the ground and the library and museum collections taken to Germany or burned. Monuments and government buildings were blown up. About 85% of the city had been destroyed, including the historic Old Town and the Royal Castle.
After World War II, under a Communist regime set up by the conquering Soviets, the "Bricks for Warsaw" campaign was initiated, and large prefabricated housing projects were erected in Warsaw to address the housing shortage, along with other typical buildings of an Eastern Bloc city, such as the Palace of Culture and Science, a gift from the Soviet Union. The city resumed its role as the capital of Poland and the country's centre of political and economic life. Many of the historic streets, buildings, and churches were restored to their original form. In 1980, Warsaw's historic Old Town was inscribed onto UNESCO's World Heritage list.
John Paul II's visits to his native country in 1979 and 1983 brought support to the budding "Solidarity" movement and encouraged the growing anti-communist fervor there.
In 1995, the Warsaw Metro opened with a single line. A second line was opened in March 2015. With the entry of Poland into the European Union in 2004, Warsaw is currently experiencing the largest economic boom of its history. Warsaw was the host city for the UEFA Euro 2012, 2013 United Nations Climate Change Conference and for the 2016 NATO Summit.