The Castle of Guimarães was built under the orders of Mumadona Dias in the 10th century to defend the monastery from attacks by Moors and Norsemen. At the end of the 11th century the castle was heavily expanded and remodeled, under the direction of Count Henry, to act as his residence. The castle became the official royal residence from 1139, when Portugal became independent from the Kingdom of León, until circa 1200.
Between the end of the 13th and beginning of the 14th century, the castle was remodelled by King Denis, resulting in the form that stands to this day. In 1369, King Henry II of Castile invaded Portugal and encircled the castle of Guimarães, but was defeated by its population and forces. Sometime between 1383 and 1433, the two towers that flank the main entrance were order built by King John I of Portugal.
After the castle's demolition was abandoned in the 19th century, many of the houses, estates and lodgings around the castle were expropriated. The first attempts at restoration occurred during the mid-20th century.
Today Guimarães castle area is delineated by walls forming a pentagram, similar to a shield, that includes eight rectangular towers, military square and central keep. Originating in the foundations of a Roman structure, from the writings of Alfredo Guimarães, it was later elaborated on the French model, in its current the form of a shield, with reduced central yard and difficult accesses. It includes several Gothic characteristics, owing to its remodelling at the end of the 13th century, when the keep and residences were constructed (possibly over pre-existing structures).
References:Celje Castle was once the largest fortification on Slovenian territory. The first fortified building on the site (a Romanesque palace) was built in the first half of the 13th century by the Counts of Heunburg from Carinthia on the stony outcrop on the western side of the ridge where the castle stands. It had five sides, or four plus the southern side, which was a natural defence. The first written records of the castle date back to between 1125 and 1137; it was probably built by Count Gunter. In the western section of the castle, there was a building with several floors. Remains of the walls of this palatium have survived. In the eastern section, there was an enclosed courtyard with large water reservoirs. The eastern wall, which protects the castle from its most exposed side, was around three metres thicker than the rest of the curtain wall. The wall was topped with a parapet and protected walkway.