Like most European cities, Ljubljana can trace its past back into the mists of time. Indeed, there is evidence of human settlement in the Ljubljana marshes dating back to 3900 BC. On the site where Ljubljana castle now stands, there is evidence of a pre-historic hill fort.
The site provides a great vantage point over the city, so it was a natural position for a defensive installation. There is some evidence that the Romans also built a fort on the site. Over time, the castle site has been built and demolished several times. The structure that can be seen today dates from 1335 AD. The castle is mentioned in records dating to 1144 AD, when it was the seat of the Counts of Spanheim, but it was probably constructed two centuries earlier. The castle became an hereditary property of the Hapsburgs in 1335 AD and controlled the Duchy of Carnolia. Duke Frederick III of Hapsburg oversaw the construction of a larger, circular structure in the later part of the 15th century. Most of the structure visible today dates from the 16th and 17th centuries, but Kapela sv. Jurija (The Chapel of St. George) is earlier, being consecrated in 1489.
The castle served as a garrison until 1814 and was subsequently uses as a provincial prison. The outlook tower (Razgledni stolp) dates from 1841. A guard stationed there was responsible for firing a cannon which was used to herald important events or visitors and also served as a fire alarm. The castle was taken over by the Municipality of Ljubljana in 1905, principally to be used for cultural events, but it was also used as residential accommodation until 1964. Currently, the castle is administered by an event management company, Festival Ljubljana. It provides the backdrop to concerts, theatrical performances, exhibitions and some official functions.
In 2006, a funicular railway was constructed to take tourist up castle hill from the old town.