During the 10th Century, after widowing from Count Hermenegildo (or Mendo) Gonçalves, the Countess Mumadona Dias assumed the government of the Portucalense County and made two decisions of great importance: she founded, on the lower part of Guimarães, the Monastery of Santa Maria (around 950) and, on the high part, a castle, the so-called Castle of S. Mamede (between 950 and 957).

The construction of this castle aimed to defend the recently built Monastery and the populations that established themselves close to these two constructions, in the meantime.  The construction of this Castle was also a way of asserting her power before the other feudal lords.  A diploma that signals the handover of the Castle of S. Mamede to the Monastery of Guimarães, on December 4, 968, was the first known reference of this fortification.