The origin of São João has its base in the early settlement of Abrantes, first documented in 1176. Afonso Henriques granted its castle to the Order of Santiago de la Espada in 1173. Three years later, he granted its fish channel to the Monastery of Lorvão. The grant was partly in aid of the residents, but entitled the King to nine-tenths of the catch. In 1179, Afonso Henriques granted a foral to Abrantes, which was confirmed by King Afonso II in 1217. On 24 April 1281, King Denis granted Abrantes to his wife, Queen Elizabeth of Portugal. He continued to expand the fort, building the detention block. With the aim of expanding the settlement, he extended its jurisdiction to include Punhete (today's Constância).