Castles in Portugal were crucial components of the military across history. The Portuguese learned the art of fortification construction from the Romans and the Moors. The Romans, who ruled and colonized the territory of current-day Portugal for more than four centuries, built forts with high walls and strong towers to defend their populations. The Moors, who invaded the Iberian Peninsula in the year 711, brought new stonework and heavily fortified gates to the peninsula.