Perched on a quartzite crag of the Serra de São Mamede, Marvão's name is derived from an 8th-century Muwallad rebel, named Ibn Marwan. Ibn Marwan, who constructed the Castle of Marvão - likely on the site of an earlier Roman watchtower - as a power base when establishing an independent statelet ("emirate", duchy) - covering much of modern-day Portugal - during the Emirate of Cordoba (884-931 CE). The castle and walled village were further fortified through the centuries, notably under Sancho II of Portugal (13th century) and Denis of Portugal.