In 1680, Portuguese colonists established Colônia do Sacramento on the northern bank of La Plata river, on the opposite coast from Buenos Aires. Spanish colonial activity increased as Spain sought to limit Portugal's expansion of Brazil's frontiers. In 1726, the Spanish established San Felipe de Montevideo on the northern bank and its natural harbor soon developed into a commercial center competing with Buenos Aires. They also moved to capture Côlonia del Sacramento. The 1750 Treaty of Madrid secured Spanish control over Banda Oriental, settlers were given land here and a local cabildo was created. In 1776, the new Viceroyalty of Rio de la Plata was established with its capital at Buenos Aires, and it included the territory of Banda Oriental. By this time, the land had been divided among cattle ranchers, and beef was becoming a major product. By 1800, more than 10,000 people lived in Montevideo and another 20,000 in the rest of the province. Out of these, about 30 percent were African slaves. Uruguay's early 19th-century history was shaped by an ongoing conflict between the British, Spanish, Portuguese, and local colonial forces for dominance of the La Plata Basin. In 1806 and 1807, during the Anglo-Spanish War (1796–1808), the British launched invasions. Buenos Aires was taken in 1806 and then liberated by forces from Montevideo led by Santiago de Liniers. In a new and stronger British attack in 1807, Montevideo was occupied by a 10,000-strong British force. The British forces were unable to invade Buenos Aires for the second time, however, and Liniers demanded the liberation of Montevideo in the terms of capitulation. The British gave up their attacks when the Peninsular War turned Great Britain and Spain into allies against Napoleon. Struggle for independence, 1811–1828 Provincial freedom under Artigas The May Revolution of 1810 in Buenos Aires marked the end of Spanish rule in the Vice-royalty and the establishment of the United Provinces of the Río de la Plata. The Revolution divided the inhabitants of Montevideo between royalists, who remained loyal to the Spanish crown (many of which remained so), and revolutionaries, who supported the independence of the provinces from Spain. This soon led to the First Banda Oriental campaign between Buenos Aires and the Spanish viceroy. Local patriots under José Gervasio Artigas issued the Proclamation of 26 February 1811, which called for a war against the Spanish rule. With the help from Buenos Aires, Artigas defeated