People had lived around here since the Paleolithic, and Celts and then Germanic tribes came and went before Slavs settled the area, probably in the 6th century. The castle on the hill grew out of a fort that stood by the year 800, and its oldest masonry dates from 885 at the latest. Vyšehrad, the other fort to the south, followed some 70 years later. Czech legend has Libuše standing on a cliff over the Vltava and foreseeing a city whose glory would reach the stars.
It grew rich as a trading town. A Jewish merchant from Spain, Abraham ben Jacob, described it in 965, and merchants from across Europe settled here, many of them Jews. The first bridge, named after Queen Judith, crossed the river in 1170. In 1257 King Ottokar II founded the Lesser Town for German settlers, who ran their own courts.
Prague flourished under Charles IV, King of Bohemia and Holy Roman Emperor, who ruled from 1346 to 1378. He planned the New Town himself and founded the university in 1347. By the 1470s Prague had about 70,000 people, and only two cities in the Empire were bigger.
Then came the reformers. Jan Hus preached against a corrupt Church at the Bethlehem Chapel from 1402 and was burned as a heretic in 1415. Four years later Prague had its first defenestration, and in 1420 Jan Žižka's peasant army and Prague's Hussites beat Emperor Sigismund on Vítkov Hill.
Under Emperor Rudolf II, who made the castle his home, Prague drew Kepler and Tycho Brahe to study the stars, Arcimboldo to paint and alchemists such as John Dee. The 17th century was the golden age of Jewish Prague, a community of some 15,000, and Rabbi Judah Loew, the Maharal, was chief rabbi from 1597 to 1609. Then it went badly for the city. The second defenestration in 1618 set off the Thirty Years' War, the rebel army lost at White Mountain in 1620, and 27 of the Protestant leaders were executed on Old Town Square the next year. The war shrank the city from 60,000 people to 20,000.
After a great fire in 1689, merchants and nobles rebuilt the city with the palaces, churches and gardens that give it its Baroque look. Joseph II merged the four historic towns into one in 1784, and the Jewish quarter, renamed Josefov, joined in 1850. German speakers fell from a near-majority in 1848 to a few per cent by 1910. Writers like Franz Kafka and Max Brod still wrote in German for the Prager Tagblatt.
In 1918 Prague became the capital of the new Czechoslovakia, with President Masaryk in the castle. On 15 March 1939 Hitler ordered German troops into the city and proclaimed a protectorate from the same castle. Most of the city's Jews were deported and murdered, and Reinhard Heydrich was assassinated here in 1942. The city rose against the Germans on 5 May 1945, and the Red Army arrived on 9 May. Around 50,000 German-speaking Praguers then fled or were expelled, ending what had been, for most of its history, a city shared between Czechs, Germans and Jews.
The Communists took power in 1948. Twenty years later Alexander Dubček's Prague Spring promised socialism with a human face, until an invasion on 21 August 1968 put an end to the reforms; Jan Palach set himself on fire the following January. Buildings were left to decay, and Wenceslas Square sat under scaffolding for more than ten years. In 1989 the Velvet Revolution filled the streets, and in 1993 Prague became capital of the Czech Republic. The clean façades you see now are mostly the work of the decades since.