Aflenz is situated at an elevation of 763 m on the southern foot of the Hochschwab massif. The first mentioning in a document (as Avelniz) dates from 1025 when King Konrad II gave land in this area to his sister-in-law Beatrix, wife of the Duke Adalbero of Eppenstein. From 1103 the village was in possession of the monastery of St Lambrecht. In 1458 Aflenz obtained the status of a market town from Emperor Friedrich III. The completion of the railway line from Vienna via Graz to Trieste (Südbahn) and of the narrow-gauge railway from Kapfenberg to Aflenz in 1893 marked the beginning of summer tourism in Aflenz. In 1920 the town was declared a climatic health resort ('Luftkurort'), and in 1979 it received the status of medical climatic health resort ('heilklimatischer Kurort'). Winter tourism on the Aflenzer Bürgeralm began to develop with the foundation of the first winter sport club in 1912. The formerly independent municipalities of Aflenz Kurort and Aflenz Land were merged into the new municipality Aflenz on 1 January 2015.
The parish church Sankt Petrus is the third church on this spot. The first church was built between 1025 and 1066 by the Eppensteiner family. The second church, a Romanesque basilica, was erected when the monastery of St. Lambrecht came into possession of Aflenz in 1103. Today's church dates from the 15th century. The tower was completed in 1451, the chancel in 1471. The nave with its splendid Gothic net vaulting was built 1490–1510. The interior decorations with paintings by Joseph Adam Mölk date from 1770–1774.