The castle was built by Mumadona Dias. She was a Countess of Portugal and ruled from about 920 to 968.