After fighting for the independence of the Viceroyalty of Rio de la Plata, José de San Martín created the Army of the Andes and crossed the Andes in 21 days. Once in Chile, he joined forces with Chilean army General Bernardo O'Higgins and liberated the country in the battles of Chacabuco and Maipú in 1818. On 7 September 1820, a fleet of eight warships arrived in the port of Paracas under the command of General José de San Martin and Thomas Cochrane, who was serving in the Chilean Navy. Immediately on 26 October, they took control of the town of Pisco. San Martin settled in Huacho on 12 November, where he established his headquarters while Cochrane sailed north and blockaded the port of Callao in Lima. At the same time in the north, Guayaquil was occupied by rebel forces under the command of Gregorio Escobedo. Because Peru was the stronghold of the Spanish government in South America, San Martin's strategy to liberate Peru was to use diplomacy. He sent representatives to Lima urging the Viceroy that Peru be granted independence, however all negotiations proved unsuccessful.