However, traces of habitation go back to the Bronze Age, and the first known inhabitants were the Celts. The Romans built a military station as a part of the near Limes Romanus on the Danube. The first written mention about the town was in 1269 in a document of the King Béla IV under name Ztumpa. In the second half of the 13th century the now-ruined Pajštún Castle in the Little Carpathians was built. It was developing mainly as an agricultural and trading settlement. The name of the town comes from the pressing mills called stupa on the Stupavský potok brook, which were used for extracting oil from flax and hemp.