After his troubling Spanish experience at the Battle of Talavera, Wellington realised that, being outnumbered by the French forces, he might need to retreat to Portugal and possibly evacuate the peninsula, so decided to strengthen the proposed evacuation area around the fort at Oeiras e São Julião da Barra Portugal. He used a report of Colonel Vincent, ordered by Junot in 1807, describing the excellent defensive capacities in the region nearby Lisbon. Historian John Grehan suggested that the study by Major Neves Costa influenced Wellington's decision to construct the lines, but in fact the plans pre-dated Costa's study. He was also inspired by the Martello Towers along the English Channel coast. In October 1809 Wellington, after surveying the area personally with Lieutenant-Colonel Sir Richard Fletcher, ordered in his detailed memorandum dated 20 October 1809 the building of the Lines of Torres as a system of fortifications blockhouses, redoubts, ravelins, cuts of natural relief, etc. The work began on several of the main defensive works in November 1809.
When the results of Royal Engineer surveyors were gathered together, it was possible by February 1810 to begin works on 150 smaller interlinking defensive positions, using wherever possible the natural features of the landscape. The work received a boost after the loss to the French of the fortress at the Siege of Almeida (1810) in August, with the public conscription of Portuguese labourers. The works were sufficiently complete when the French troops arrived in October to make them stop and fall back. Even after the French had retreated from Portugal, construction of the lines continued, and in 1812 34,000 men were still working on them.
The work was supervised by Fletcher, assisted by Major John Thomas Jones, and 11 other British officers, four Portuguese Army engineers, and two KGL officers. The cost was around £100,000 (close upon £200,000 per the Corps of Royal Engineers), one of the least expensive but most remunerative military investments in history.
The country from Torres Vedras to Lisbon resembles nothing so much as a gigantic mountain-torrent instantaneously converted into solid earth. The ground flows down from north to south in great undulations, which now and again throw up abrupt peaks ending in a knob of bare rock, only to plunge down again into deep gullies and ravines; the character of the whole being rugged and inhospitable, and suggesting even at first sight innumerable facilities for a stubborn rear-guard fight.
Wellington's earliest idea had been to construct his first line from Alhandra on the east to Rio São Lourenço on the west, with advanced works at Torres Vedras, Monte de Agraço, and other commanding points. The tardiness of Masséna's movements, however, had enabled him to strengthen the first line sufficiently to warrant his holding it in permanence. Surveying this line from east to west, the first section from Alhandra almost to Arruda was about 5 miles (8.0 km) long, of which 1 mile (1.6 km), towards the river Tagus, had been inundated; more than another 1 mile (1.6 km) had been scarped into a precipice, and the most vulnerable point had been obstructed by a huge abatis. The additional defences included 23 redoubts mounting 96 guns, besides a flotilla of gunboats to guard the right flank on the Tagus; and this portion of the ground was occupied by Hill's division.