The Lines of Torres Vedras were lines of forts and other military defences built in secrecy to defend Lisbon during the Peninsular War. Named after the nearby town of Torres Vedras, they were ordered by Arthur Wellesley, Viscount Wellington, constructed by Sir Richard Fletcher, 1st Baronet, and his Portuguese workers between November 1809 and September 1810, and used to stop Marshal Masséna’s 1810 offensive.

Wellesley led his men back to the temperate valleys of Beira and Mondego in southern Portugal. After their gruelling marches the mood of relief and lightheadedness in this cheerful winter quarters is caught by the episode when Wellesley, visiting a convent, was astonished to see a nun perform a somersault – until from her petticoats there emerged the boots of a British officer, the practical joker being Captain Dan Mackinnon (who also dressed up on another occasion as the Duke of York, fooling his Spanish hosts, until he dunked his head into the punchbowl in front of him).

Wellesley had now been awarded a peerage as Viscount Wellington, after the town in Somerset. The new milord knew that his position in Portugal was virtually impregnable because Lisbon, from which British forces could be evacuated by sea in a crisis, was at the tip of a peninsula twenty miles wide with the Tagus encircling it to the south and east and the Atlantic to the west. If he built fortifications across the neck of the isthmus on the hills to the north – which rose to 2,000 feet in some places – he had a defensible enclave.

At the end of October he ordered his chief engineer, Colonel Fletcher, to start building these lines of defence – one at the bottom of the Peninsula to cover an embarkation, another across the Cabeca de Monchique, a mountain area which formed an outer perimeter six miles to the north. The extent of the work was astounding: forests were cut down, walls erected and towers strung out along the lines. Much of this work, called the Lines of Torres Vedras, survives to this day, more than fifty miles in extent – a miniature version of the Great Wall of China.

While the Lines were being constructed, Wellington had to fight calls from England for the withdrawal of his army. He was accused of causing his men needless suffering after Talavera, which was partly true. With the fall of the Duke of Portland’s government, the new secretary for war was Lord Liverpool, a pleasant, deeply unimaginative mediocrity but a staunch admirer of Wellington. The latter defended himself with uncharacteristic modesty and urged a continuing presence in the Peninsula: ‘During the continuance of this contest, which must necessarily be defensive on our part, in which there may be no brilliant events, and in which, after all, I may fail, I shall be most confoundedly abused, and in the end I may lose the little character I have gained; but I should not act fairly by the government if I did not tell them my real opinion which is, that they will betray the honour and interests of the country if they do not continue their efforts in the Peninsula, which, in my opinion, are by no means hopeless.’

Liverpool was persuaded: ‘We must make our opinion between a steady and continued exertion upon a moderate scale and a great and extraordinary effort for a limited time which neither our military nor financial means will enable us to maintain permanently. If it could be hoped that the latter would bring the contest to a speedy and successful conclusion, it would certainly be the wisest course; but unfortunately the experience of the last fifteen years is not encouraging in this respect.’

Not since Addington had so mediocre a man as Spencer Perceval led Britain against France. Brougham sums up his personality:

Of views upon all things the most narrow, upon religious and even political questions the most bigoted and intolerant, his range of mental vision was confined in proportion to his ignorance on all general subjects. Within that sphere he saw with extreme acuteness – as the mole is supposed to be more sharp-sighted than the eagle for half a quarter of an inch before it; but as beyond the limits of his little horizon he saw no better than the mole, so like her, he firmly believed, and always acted on the belief, that beyond what he could descry nothing whatever existed; and he mistrusted, dreaded, and even hated all who had an ampler visual range than himself. But here, unhappily, all likeness ceases between the puny animal and the powerful statesman. Beside the manifest sincerity of his convictions, attested, perhaps, by his violence and rancour, he possessed many qualities, both of the head and the heart, which strongly recommended him to the confidence of the English people. He never scared them with refinements, nor alarmed their fears by any sympathy with improvements out of the old and beaten track; and he shared largely in all their favourite national prejudices.

Perceval’s absurd attempts to secure a monopoly of neutral trade for Britain led to the needless War of 1812 with America. In the absence of both Canning and Castlereagh, the most powerful players in his government were the Wellesley brothers – the marquess promoted from ambassador to Lisbon to Foreign Secretary – with Liverpool another mediocrity whom they dominated. Perceval was a narrow-minded conservative, whose response to the threat posed by Napoleon was of straightforward obduracy, as it was to any manifestation of popular discontent prompted by Britain’s economic difficulties under the Continental System and the rapid social and economic transformation the country was undergoing.

The sole benefit of such leadership was that it gave the domineering Wellington a free hand in Portugal. In addition to establishing the Lines of Torres Vedras, Wellington proved a genius in irregular warfare. He sought to integrate his Portuguese troops under General Beresford. In this Major Harvey, the assistant quartermaster-general with the Portuguese army, was the key. He was sent to organize a force of Portuguese guerrillas in Beira province. These became highly effective guerrillas, usually under the command of priests. On one occasion Harvey’s irregulars captured a heavy convoy near Penamacor, fighting off the 150 French irregulars accompanying it just four miles away from a full French division: no fewer than fifty-three cartloads of ammunition and tobacco were taken.

Another leader of irregulars was the ferociously disciplinarian Brigadier Robin Crauford, ‘Black Bob’, who flogged any man who broke ranks crossing a stream and who could get his men under arms from sleeping quarters at night in just seven minutes. Crauford’s guerrillas guarded the Portuguese frontier, bringing reports of suspect French troop concentrations. ‘The whole web of communication quivered at the slightest touch,’ wrote one observer admiringly. Both Harvey and Crauford reported back enemy movements in the valley of the Mondego from the vantage points of the Serra d’Estrella.

Wellington and his small army remained in their hill fastnesses in central Portugal, as Washington’s armies had done in the interior of America, while the imperial armies of their opponents blundered about the plains and plateaux, under constant and relentless harassment from the local population. Every day on average more than a hundred French soldiers were killed. While bungling and ill-equipped Spanish armies were always at the mercy of the French on the field of battle, in guerrilla fighting it was the other way around.

One fearsome guerrilla boasted that he had killed 600 Frenchmen himself. El Empecinado – Inky Face – roamed Castile with his guerrilla band, seizing and holding the sizeable town of Guadalajara for a day. Camilo, a guerrilla chief whose wife and daughter had been raped, formed a small army which killed thousands. Don Julian Sanchez sent the severed heads of French commanders to Wellington as trophies and massacred 160 prisoners in a single sitting, promising to slice Soult into strips. One of his commanders boiled a French general alive and sawed another in half.

The fortress of Gerona held out under its governor, Mariano Alvarez de Castro. He told his men when they ran out of food to eat the cowards, and instructed his officers that their only place of retreat should be the cemetery. Half of Gerona’s townspeople and 6,000 of its 9,000 defenders were killed before it surrendered.

Napoleon, relaxing with his pretty young bride after Wagram, had long promised to go to Spain to take personal charge of the campaign but perhaps sensing that the war there was unwinnable against resistance on this scale, he had already despatched his two best generals, André Masséna and Michel Ney. These two supported the forces under the incompetent King Joseph (known as Pepe Botellas by the Spaniards for his alleged fondness for the bottle), and other marshals: Soult in Andalucia, Suchet in Aragón (who alone controlled his fiefdom through enlightened policies designed to win over the local population) and Augereau in Catalonia. These men reported directly to the Emperor in order to prevent Masséna acquiring too much power, but the result was that they competed with one another, rarely combining their armies. They each ran their own areas of Spain as personal fiefdoms.

Wellington wrote with detachment in July:

This is not the way in which they have conquered Europe. There is something discordant in all the French arrangements for Spain. Joseph divides his Kingdom into préfetures, while Napoleon parcels it out into governments; Joseph makes a great military expedition into the south of Spain and undertakes the siege of Cadiz while Napoleon places all the troops and half the kingdom under the command of Masséna and calls it the Army of Portugal . . . I suspect that the impatience of Napoleon’s temper will not bear the delay of the completion of the conquest of Spain.

But Masséna with his 30,000 vanguard was already approaching the frontier town of Ciudad Rodrigo. Although the fortress was almost indefensible, its heroic Spanish commander General Herrasti held out for nearly two months with 5,000 men, until more than 1,200 had been killed. Some 30,000 shells and roundshot had to be fired before the French managed to take the garrison. Wellington refused to come to the rescue, for once out in the open plain he was easy prey for French cavalry. Masséna’s army now moved on to the more impressive fortress of Almeida. However, here a shell blew up the main ammunition dump, leaving the garrison almost out of ammunition, and it surrendered unexpectedly quickly.