In the 9th century, Afonso III of León established the Land of Santa Maria, entrusting its leadership to the military fortress of Cívitas Sanctae Mariae. This fortress played a crucial role as an advanced stronghold against Arab invasions, heroically resisting the onslaughts of Almansor in the year 1000. The resilient Christian population, twice, reconquered the castle, keeping the name of Civitas Sancta Mariae alive, bearing witness to their courage and religious convictions.

During the reign of Bermudo III in the early 11th century, the region faced another Arab invasion, but governors Men Guterres and Men Lucídio led a notable reconstruction of the castle after the victory at the Battle of Cesár. Recognition for this achievement was expressed in the granting of the “Honra de Infanções,” a distinction of great prestige comparable only to the leaders of Lisbon in the 14th century.

The “Land of Santa Maria” remained for years as a border with the Arabs until the conquest of Coimbra in 1067. After this event, it became a breeding ground for knights and foot soldiers supplying the southern front, reflecting the permanent military organization established in the region.

After the death of Count D. Henrique, the widow, D. Teresa, became involved with Fernão Peres de Trava, resulting in a growing Galician influence in the County of Portucale. Great Portucalan families, such as Moniz and Sousas, faced economic and administrative confrontations, culminating in a revolt.

Ermígio Moniz and Pero Gonçalves do Marnel, notable figures of this revolt, played fundamental roles. With the support of Infante D. Afonso, the forces of Santa Maria marched to Guimarães against Galician influence. On June 13, 1128, the Galician troops were defeated, marking a crucial point in the history of Portugal, not as a cause but as a consequence of a collective independence movement led by figures like Ermígio Moniz and Pero Gonçalves de Marnel, strongly connected to the Land and the Castle of Santa Maria.