The origins of the town date back to the 11th century. It was a forest settlement, with a wooden castle built along the border of Lesser Poland and Silesia. In 1241, during Mongol invasion of Poland, the village and the castle were burned, and afterwards, a new, stone castle was built. Ogrodzieniec received its Magdeburg rights town charter in 1386. It was a local trade center, with merchants and artisans, many of them Jewish. Furthermore, enormous forests attracted noble hunters, including Polish kings. In 1346, Ogrodzieniec Roman Catholic parish church was first mentioned. In the mid-16th century, it was turned into a Calvinist prayer house, and remained so until circa 1630, when it was returned to the Catholics. In the first half of the 18th century, a new, stone church was built, but it was not completed until 1787. Until 1795, Ogrodzieniec belonged to Kraków Voivodeship. After the third partition, it was annexed by the Kingdom of Prussia, and belonged to New Silesia. Since 1815, it belonged to Russian-controlled Congress Poland, and in 1888, when already a village, Ogrodzieniec had 162 houses, with app. 1,000 inhabitants. In the Second Polish Republic, Ogrodzieniec belonged to Kielce Voivodeship, and in 1939, the village was annexed directly into the Third Reich. German occupiers planned to change its name into Bonerburg. After the war, until 1956, Ogrodzieniec belonged to Olkusz County of Kraków Voivodeship, then it was moved to Zawiercie County.
Due to the existence of the Ogrodzieniec Castle, the town is a popular tourist center, located on the Trail of the Eagles' Nests. The castle was built in the 14th century by the Sulimczyk family. It is located on Góra Zamkowa, the highest hill of the Polish Jura. First stronghold was built here in the early 12th century, during the reign of Bolesław III Wrymouth. In 1241, during the Mongol invasion of Poland, it was burned and destroyed, and in the mid-14th century, new, stone complex of a mighty Gothic castle was built here. The castle guarded western border of Lesser Poland, and in 1470 it was purchased by the Salomon family, merchants from Kraków. It then changed hands several times, belonging to the Rzeszowskis, Pileckis, Chełmińskis and finally, the Boner family. In 1530 - 1545, Seweryn Boner turned the Gothic stronghold into a Renaissance residence. In 1562, Boner’s daughter Zofia married Jan Firlej, and the castle, as a dowry, changed hands once more. In 1587, it was captured by Maximilian III, during the War of the Polish Succession. In 1655, it was seized by Swedes. Swedish garrison stayed at the castle for two years, which resulted in its extensive damage. In 1669, the castle was partially restored by its new owner, castellan of Kraków Stanisław Warszycki. In 1695 it was purchased by the Męciński family, and in 1702, once again it was destroyed by Swedish soldiers, during the Great Northern War. After the destruction, the castle remained a ruin, and its subsequent owners could not afford to rebuild the complex. It remained inhabited until circa 1810.
After World War II, the castle was nationalized, and its walls were strengthened in 1949 - 1973, which prevented total collapse of the complex. It now has a status of permanent ruin, and is open to visitors. The castle is popular among film makers; in 1973, some episodes of the TV seriesJanosik were made here, and in 2001, Andrzej Wajda shot The Revenge here. Furthermore, in 1984 the castle was presented in Iron Maiden’s video Behind the Iron Curtain, in the song "Hallowed Be Thy Name". Also, in the Australia television series Spellbinder, the castle was used as the ruins of the castle of the old Spellbinders.