Hainburg is located on the right bank of the Danube river, 4 km southwest of Devín (Slovakia), 12 km west of the Slovak capital Bratislava and 43 km east of the Austrian capital Vienna. It is part of the Industrial Quarter Industrieviertel in Lower Austria.
45.87% of the land is forested, 54.13% is used for agriculture and urban areas.
In the second half of the 12th century, the ransom received from Richard the Lionheart built the castle along with the Viennese gate around 1220 to 1225. The lower part wasn't built until 1267 to 1268 by Ottokar II of Bohemia.
Here Joseph Haydn the composer came as a six-year-old child to learn the rudiments of music from his relative Josef Mathias Franck, and to sing as a choirboy from 1737–1740. There is a Haydn Fountain on the Hauptplatz in the town.
Hainburg gained a garrison in the 19th century.
Since the end of the First World War, Hainburg has been the easternmost town in Austria.