In the 5th and 6th centuries, an Alamanni village existed. The oldest registered usage of the name "Lencis" (from which Lenzburg derives) is from 893. In 1036, Castle Lenzburg became the seat for the count of Lenzburg, then an important lord. The family died out in 1173, and the castle was then owned by emperor Frederick Barbarossa. After this, it was mainly used by the Kyburger house. The Habsburgs took over the castle in 1273.