Ourém enjoyed a period of splendour in the 15C, when the fourth Count of Ourém, Dom Afonso, son of the first Duke of Bragança and nephew of Constable Nuno Álvares Pereira, had the castle converted into a palace and several monuments built. More than 2 000 people lived within the castle walls - note the curious brick machicolations.