The Monroe Doctrine was a foreign policy of the United States that was proclaimed in 1823 during the presidency of US President James Monroe but had been the idea of Secretary of State John Quincy Adams. It stated that no European power could colonize any more of the Americas or of the Western Hemisphere in general.
In particular, most of the Spanish Empire in South America had recently become independent because of the Napoleonic Wars against France. Having won the Peninsular War, Spain wanted its empire back, which the Monroe Doctrine stated that the United States would resist. The United Kingdom agreed because it wanted to trade with the newly-independent countries and so it helped enforce the Monroe Doctrine by its powerful Royal Navy.