Under the King Denis (1261-1325), Marvão benefited from the king's focus on bolstering Portugal's border with the neighbouring Kingdom of Castile. King Denis's border pact with Ferdinand IV of Castile (1297) was followed by considerable investment in a chain of Portuguese castles along the border, with Marvão castle being considerably extended from 1299 onwards using Hospitaller expertise. On the Castilian side of the border, castles were likewise reinforced at nearby Valencia de Alcántara and Mayorga, the Order of Alcántara being a Castilian counterpart to the Hospitaller's role in Portugal.