In 1822, Brazil claimed to be its own country and not a part of Portugal anymore. Soon there was civil war. Meanwhile, the quilombos survived and Brazil was bringing in more slaves than any other country in the Americas, even though many countries were beginning to legally abolish slavery. This led to an increase in slave revolts, especially in the 1860s and 1880s, which forced the government to change the system in order to keep the country stable. Slavery was legally abolished in 1888.