In 1807, Spain and France invaded and occupied Portugal, an ally of the United Kingdom. The Spanish people were upset by the presence of French troops in Iberia. After a revolt by Spanish Troops and an uprising in Madrid, Napoleon forced King Charles IV and Prince Ferdinand to abdicate and installed his brother, Joseph Bonaparte as King of Spain. This was followed by further revolts across Spain. In August 1808, a British Army landed in Portugal. Britain and France then went to war against each other in Portugal and Spain. The war and instability in Spain affected Mexico and other parts of New Spain.