Emblematic of the medieval Portuguese castle, Guimarães is associated with the origins of the Portuguese nation. Yet, the phases and organization involved in its construction, from the 10th century onwards is very deficient, with many of its present structure resulting from its reconstruction in the second half of the 13th century. The examination of its walls and remains led Carlos A. F. de Almeida to proclaim, for example, that the flanking towers were constructed during the late Romanesque, early Gothic period.
In the second half of the 10th century, owing to the death of Count Hermenegildo Gonçalves, the property of Vimaranes (today Guimarães) was inherited by his daughter Oneca. Countess Mumadona Dias, the count's widow, traded her property in Creiximir for the land in Vimaranes, and ordered the construction of a monastery situated on land today occupied by the Collegiate and
Church of Nossa Senhora da Oliveira (PT010308340007). Later, in order to defend the curate at the monastery, the countess ordered the construction of the castle. By 4 December 968, a codicil, the countess referred to the castle (then designated as the Castle of São Mamede) as just having been constructed, in order to defend the friars and nuns in the monastery.
At the end of the 10th century, Dias's eldest son, Gonçalo Mendes, takes possession of the lands following her death and maintaining her wishes to support the monastery.