Although settlements existed on the site of Warsaw in the 11th cent., the city probably grew around a castle built in the 13th cent. by a duke of Mazovia. In 1413, Warsaw became the capital of the duchy of Mazovia, which was incorporated with Great Poland in 1526. After Kraków burned, Warsaw replaced it (1596) as Poland's capital. Warsaw grew rapidly as a commercial and cultural center, despite frequent invasions and pillages. It fell temporarily to the Swedes under Charles X (1655–56) and Charles XII (1702), was occupied by the Russians in 1792 and 1794, and passed to Prussia in 1795.
Liberated by Napoleon I in 1806, it became (1807) the capital of the grand duchy of Warsaw (see Poland) and was the scene in 1812 of a diet that proclaimed the reestablishment of Poland. In 1813, however, the city fell to the Russians, and in 1815 it became the capital of the nominally independent kingdom of central Poland, awarded by the Congress of Vienna to the Russian crown. Warsaw was the principal center of unsuccessful Polish uprisings against Russian domination in 1830 and 1863.
German forces took the city in 1915, during World War I. In Nov., 1918, it was liberated by Polish troops and proclaimed capital of the restored Polish state. In 1920 the Polish defense of Warsaw, led by the French general Maxime Weygand, turned the tide of the Russo-Polish War. The city was the scene in 1926 of a military coup that established Marshal Joseph Piłsudski's dictatorship.
During World War II the city was occupied (1939–45) by German troops and subjected to systematic destruction. In 1940 the Germans isolated the Jewish ghetto, which in 1942 contained about 500,000 persons. In reprisal for a Jewish uprising (Feb., 1943) in the ghetto, the Germans killed an estimated 40,000 of the Jews who had survived the battle. When Warsaw was liberated (Jan., 1945) by Soviet troops, only about 200 Jews remained.
From Aug. to Oct., 1944, some 40,000 members of the Polish nationalist underground and German troops battled for Warsaw. While the battle was raging the Soviet army, which was camped across the Vistula and which the partisans had hoped would come to their aid, remained inactive. The Germans routed the rebels and following their victory carried out severe reprisals, killing or expelling Warsaw's inhabitants and deliberately demolishing the city. By October about 15,000 partisans and more than 200,000 civilians had been killed and the city lay in ruins. The postwar decision to retain Warsaw as the national capital resulted in a large-scale reconstruction. In 1955, the Warsaw Pact established the now-defunct Warsaw Treaty Organization, the Eastern European counterpart to NATO.