In 1139, the settlement was taken by Leonese troops from the Moors and a castle reconstructed on the site. It eventually began to pertain to the Order of São João do Pereiro. A 1227 Latin document referred for the first time to Vilar Maior, a toponymy that was associated with the early small colony; "vilar", which is a diminutive of "vila" (or town) referred to the site occupied by a group of one of two families.
In 1230, the site was reconquered by Leonoses forces from Portuguese troops. On 6 August 1232, a letter was issued by King D. Alfonso IV of León to encourage settlement in the region. But this was annulled by King D. Fernando II of León, who reintegrated Vilar Maior into the municipality of Sabugal. His successor was then responsible for the reconstruction of the castle in the intervening years.
Between 12th and 13th century, the location was easily defended by natural defenses, but with the advent of canons the site began to be considered vulnerable. By the second half of the 13th century, a new settlement letter was issued by King D. Alfonso X of Castile. By 1280, from an inscription, the urban perimeter wall ordered constructed by Alfonso X of Castile or, at least, the line that terminated at the Rua do Arco was concluded.
In 1296, the castle was conquered by forces loyal to King D. Dinis, at the time garrisoned by Leonese D. Sancho Peres de Ledesma. A foral (charter) was conceded on 27 November 1296. The castle, or at least the keep tower, was constructed by King Dinis, with the assistance of the Knights Templar. By 12 September 1297, the territory was integrated into the Portuguese kingdom, during the sequence of the Treaty of Alcanices.