Although the early human occupation of the region dates back to prehistoric times, an archaeological campaign undertaken in 1997 revealed a Phoenician wall of section dating from the eighth century BC. This colony of sailors and traders was the first proof of establishment.
When the Romans invaded the Iberian Peninsula, the village, then called Balsa, acquired strategic importance due to the presence of a bridge over the river.
The town later came under the control of the Moors in their conquest of the region.
At the time of the Christian reconquest of the peninsula, Portuguese forces reached the eastern Algarve from 1238. Tavira was conquered on 11 June 1239 (May 1240, according to Alexandre Herculano or even 1242 according to other sources), by the forces under the command of D. Paio Peres Correia, Master of the Order of Santiago. Tradition associates this achievement with a reprisal by that Order for the death of seven of its knights in an ambush while hunting on the site of Antas, in the current parish of Luz.
On 9 January 1242 (or 1244 according to other sources), Sancho II of Portugal (1223–1248) donated the domains of Tavira and the patronage of his church to the Order of Santiago, a donation confirmed in 1245 by Pope Innocent IV.
Pretending that the city had been conquered by a Castilian Military Order, Alfonso X of Castile claimed it for himself, coming to impose siege and conquer it in 1252. The following year, a treaty was signed by which Alfonso III of Portugal (1248–1279) would marry Afonso X's daughter and, if that union resulted in a son who would turn seven, his maternal grandfather would give him the gift of the Algarve. Since the conditions of this legislation were fulfilled in 1264, Afonso X delivered the Algarve to Afonso III by letter of 20 September, set in Seville. Because of this act, the Portuguese sovereign granted foral letters to various Algarvian villages, the first of which Tavira in August 1266.