Heidenheim was first mentioned in the year 742. During that time, the
double monastery of Heidenheim am Hahnenkamm (housing monks and nuns) was founded by
Saint Willibald and was later led by
Saint Walpurga, who became abbess after his death. Secular power was represented in turn by the Earl of Truhendingen (Altentrühdingen), the Duke of Bavaria, and the
Hohenzollern burgrave of
Nuremberg. Thereafter, the town belonged to the
Principality of Ansbach. The monastery was closed in 1537 due to the
Reformation. Since then, Heidenheim has been mostly Lutheran. In 1792,
Prussia bought the Principality of Ansbach, bringing Heidenheim under Prussian rule. As part of Ansbach, Heidenheim was transferred back to
Bavaria due to the . ==See also==