Spain had controlled Lima since the 16th century, when it defeated the Incas. In the centuries that followed, the Roman Catholic Church gathered a huge treasure in Lima. In the early 19th century, Spain began to have difficulties with its colonies due to wars of independence in South America. Lima was no exception, and in 1820 the city came under heavy pressure and finally had to be evacuated. (See also Peruvian War of Independence.)