Other theory states that the castles reflect the fact that the king that placed them in the flag (D.Afonso III) was son of D.Urraca, a castilan princess, because the castles were a symbol of the castilian royal family.
The seven castles are traditionally considered a symbol of the Portuguese victories over their Moorish enemies, under Afonso III, who supposedly captured seven enemy fortresses in the course of his conquest of the Algarve, in 1249. Yet, this is nothing more than popular belief because this king did not have seven castles on his banner, but an unspecified number. Some reconstructions display about sixteen castles; this number changed to nine, in 1385, and was only fixed at seven, in 1485. An hypothesis about the origin of the castles on a red bordure lies in the connection of Afonso III with Castile (his mother and second wife), whose arms consisted of a yellow castle on a red field.