The movement for independence by the Spanish colonies began around the end of the 18th century, when Spain, devoting its energy and troops to the war against France, began to lose control of the colonies. By the end of the war in 1814, Venezuela and Argentina had effectively declared independence from Spain, and over the next seven years, the other Spanish colonies followed suit. Brazil became autonomous in 1807 and declared independence in 1822.