Alexandr of Novgorod defeated the Swedes near the mouth of the Neva in 1240 - earning the title Nevsky (of the Neva). Sweden took control of the region in the 17th century and it was Peter the Great's desire to crush this rival and make Russia a European power that led to the founding of St Petersburg. At the start of the Great Northern War (1700-21) he captured the Swedish outposts on the Neva, and in 1703 he founded the Peter & Paul Fortress on the Neva a few kilometres in from the sea. After Peter trounced the Swedes at Poltava in 1709 the city he named (in Dutch style) Sankt Pieter Burkh really began to grow. Canals were dug to drain the marshy south bank and in 1712 he made the place his capital, forcing administrators, nobles and merchants to move here and build new homes. Peasants were drafted in for forced labour, many dying for their pains. Architects and artisans were brought from all over Europe. By Peter's death in 1725, his city had a huge population and 90% of Russia's foreign trade passed through it.
Peter's immediate successors moved the capital back to Moscow but Empress Anna Ivanovna (1730-40) returned to St Petersburg. Between 1741 and 1825 under Empress Elizabeth, Catherine the Great and Alexander I it became a cosmopolitan city with a royal court of famed splendour. These monarchs commissioned great series of palaces, government buildings and churches, which turned it into one of Europe's grandest capitals.
The emancipation of the serfs in 1861 and industrialisation, which peaked in the 1890s, brought a flood of poor workers into the city, leading to overcrowding, poor sanitation, epidemics and festering discontent.