Following the Treaty of Fontainebleau signed between France and Spain in October 1807, which agreed on the invasion of Portugal, French troops under the command of General Junot entered the country, which requested support from the British. In July 1808 troops commanded by Arthur Wellesley, 1st Duke of Wellington landed in Portugal and defeated French troops at the Battles of Roliça and Vimeiro. This forced Junot to negotiate the Convention of Cintra, which led to the evacuation of the French army from Portugal. In March 1809, Marshal Soult led a new French expedition that advanced south to the city of Porto before being repulsed by Portuguese-British troops and forced to withdraw. However, the threat of further invasions by the French led Wellington, on October 20, 1809, to order the construction of defensive lines to the north of the capital, between the Atlantic Ocean and the River Tagus. The Lines of Torres Vedras, consisting of 152 forts, redoubts and other military installations, were built rapidly and in conditions of great secrecy, under the overall supervision of Colonel Richard Fletcher who was commander of the Royal Engineers.