People hunted here between 24,000 and 22,000 BC: knapped stones from that time turned up at Ametzagaña, between Intxaurrondo and Astigarraga. Romans settled by about 50 AD in what is now the Old Town, on the slopes of Urgull. The name is plainer than it looks. Donostia and San Sebastián both mean Saint Sebastian, and the Basque dona element means saint.
The first written record is from 1014, when a monastery of Saint Sebastian with apple orchards for cider was reportedly given to the Abbey of Leire. In 1181 King Sancho VI of Pamplona gave the town its charter. Castile took it in 1200, and settlers from Bayonne and beyond arrived to populate the strip under Urgull. They spoke Gascon, and the people of the San Vicente parish still did in the early 18th century. A fire in 1489 burned the wooden town to the ground, and it was rebuilt mainly in stone.
Sitting next to the French border was costly. Walls went up, and the town helped Emperor Charles V in the 1520s, which earned the titles Muy Noble y Muy Leal on its coat of arms. War and disease pushed fishermen and traders into privateering. Then came better times: the Guipuzcoan Company of Caracas, founded in 1728, boosted trade with the Americas. Its profits paid for urban improvements, and the Santa Maria church went up by subscription.
The worst night came on 31 August 1813. British and Portuguese troops, besieging the town during the Peninsular War, stormed it, then ransacked it and burned it. One street at the foot of the hill survived, and it is still called 31 August Street. The Old Town you walk through today is the rebuilding: neoclassical, systematic, and austere. Constitution Square dates from 1817.
In 1863 the walls came down, and the town began to expand. José Goicoa and Ramón Cortazar laid out a grid in Parisian style. Goicoa designed the Miramar Palace and the La Concha Promenade, and the Spanish monarchy chose the town for its summers, copying the French at nearby Biarritz. From 1885 the widow of Alfonso XII, María Cristina, spent every summer at Miramar. The wave baths at La Concha clashed with the shipbuilding there, so the shipyards moved to Pasaia.
The First World War brought Mata Hari, Leon Trotsky and Maurice Ravel. Then the good years ended: the Primo de Rivera dictatorship banned gambling in 1924, which hurt the Grand Casino and the Kursaal. The 1936 coup was beaten back in the city at first, but the province fell to Franco's side later that year. From 1936 to 1943, 485 people were executed after show trials, and the city lost somewhere between 40,000 and 50,000 residents. In 1943 Elvira Zipitria opened the first Basque-language schools, teaching from her home in the Old Town. Franco spent his summers at the Aiete Palace until 1975.
Factories pulled in migrants from the rest of Spain, and the outskirts grew fast and unplanned. Altza went from 2,683 people in 1910 to 32,531 in 1970. Protest and ETA activity led the Franco authorities to declare Gipuzkoa's first state of emergency in 1968. The city held its first democratic municipal elections in 1979. From the 1990s it cleaned up the centre, enlarged Zurriola beach and opened the Kursaal cubes in 1999. In 2016 it shared the title of European Capital of Culture with Wrocław.