The Kobencl family was one of the most prominent noble families in the Gorizia county in the Modern Period. Said to have originated in Carinthia, the family is first mentioned already in the 13th century.
Firmly established in Carniola by the 16th century, besides Štanjel, the family owned many other seigniories located in the present-day Vipava Valley, the Goriška and Italian Karst, Notranjska and Friuli-Venezia Giulia. It shaped the fortunes of Štanjel up until 1810 when the last male descendant of the family, Janez Filip, Count Kobencl, passed away.
The Kobencl noble family was awarded the Štanjel feudal estate by the Habsburgs in 1508. The member of the Cobenzl family to be first mentioned was Krištof Cobenzl, a superintendent and commander who unsuccessfully defended Štanjel against the Venetians in the first year of the Austrian-Venetian war (1508–1516). Austrian authority was re-established in Štanjel in the following year (1509).
After the war, Štanjel was systematically reinforced with walls, mostly to improve its defence capability on the new western border of the Hapsburg Monarchy. The castle, located in the tower on top of Turn Hill, had been burnt down and demolished during the war and was not later renovated. Instead, its stones were used to repair the damaged and poorly protected fort. In the 16th and 17th centuries, Gledanica was a quarry. The new castle, which held administrative functions with respect to the estate, was built on the most north-western part of the village, near the outer bailey of the former tower-shaped castle. In the first half of the 16th century, a new external wall was built around Štanjel, which concentrically encompassed about four times more area than the former wall dating from the last third of the 15th century. According to the years inscribed on some preserved memorial plaques, the Cobenzl family started to rearrange the castle in 1583, gave it a Baroque/Renaissance image in about 1661 and, 8 years later, joined the two-wing residence with a curtain wall and a monumental Renaissance portal.
The Kobencl family provided many reputable representatives of high-standing for the Hapsburg Monarchy. They performed many important diplomatic functions from the 16th to early 19th century. Apart from diplomatic ones, they held top positions in the Hapsburg nobility, including: Trieste and Gorizia captains, Carniolan provincial governors and hillfort chieftains, Carniolan provincial vicedoms and many other important positions.