During the early Middle Ages, the Swabians, Visigoths and eventually the Umayyad Arabs began to settle in the area. The construction of the castle at Marvão was attributed to 9th century Islamic knight, Ibn Marwan, who began to dwell in the castle between 876 and 877. By the beginning of the 10th century, the settlement was designated Amaia de Ibn Maruán or, alternately, the fortress of Amaia. Christian forces loyal to King D. Afonso I (1112–1185) conquered the region and town from Moorish forces sometime between 1160 and 1166.
With the demarcation of Castelo Branco in 1214, Marvão was already included within Portuguese territory. The first foral (charter) was issued in 1226 by King D. Sancho II (1223–1248), done to ensure the development of the unpopulated outpost, against repeated attacks from the Kingdom of Castile. The castle briefly fell into Almohad hands in the 1190s.
Within the next few years, King D. Afonso III donated the fortified settlement to the Order of Malta (1271), later awarded to his son, D. Afonso Sanches, along with landlords of the castles in Arronches, Vide and Portalegre. For this reason, at the beginning the reign of King D. Dinis (1279–1325), the village and its castle found themselves involved in the dispute between the sovereign and D. Afonso, and was conquered by the forces of the sovereign in 1299. At the end of these events, the fields of Marvão, Portalegre and Arronches were exchanged for those in Sintra and Ourém, becoming regal possessions/property by 1300. D. Dinis issued a new foral, and undertook the expansion and strengthening of defenses, resulting in the construction of the keep.
During the reign of Ferdinand I of Portugal (1367–1383), the king established Marvão for a place of sanctuary (1378). His death immediately sparked the 1383-1385 Portuguese succession crisis, and was included in the possessions of the Order of Avis. The new sovereign and his successors granted many privileges to the village in 1407, 1436 and 1497 aimed at increasing its settlement and defense.