Sopron has had more wars, difficult decisions and political rulings thrust upon it than most other Hungarian cities. Indeed as recently as 1921 its citizens had to vote whether to stay in Austria's Bürgenland as a result of the Trianon Treaty or be reannexed by Hungary. They resoundingly chose the latter, which explains the little knot of Hungarian territory that juts into Austria.
First to arrive in the area were the Celts, then came the Romans, who lived in a settlement called Scarbantia (now Sopron's Inner Town) between the 1st and 4th centuries. The Germans, Avars, Slavs and the Magyars followed in succession. In medieval times Sopron was ideally situated for trade along the so-called Amber Route from the Baltic Sea to the Adriatic and Byzantium. By the 1300s, after a century of struggle between the Hungarians and the Austrians for hegemony over the city, Sopron had been made a royal free town - its mixed population able to pursue their trades without pressure from feudal landlords. Thus a strong middle class of artisans and merchants emerged here, and their wealth contributed to making Sopron a centre of science and education.
Neither the Mongols nor Turks were able to penetrate the heart of Sopron, which is why so many old buildings still stand. But damage during WWII was extensive - the area saw much restoration work done in the 1960s.