The Napoleonic wars were taking place in Europe, involving France, Great Britain and most European countries. Portugal broke the blockade imposed on British trade and, as a result, was invaded by France. However, the Royal Family and the bulk of the kingdom's administration fled to colonial Brazil, in a move to preserve Portuguese sovereignty. Under the pretext of reinforcing the Franco-Spanish army occupying Portugal, French Imperial troops began filing into Spain. Shortly before the Spanish King Charles IV abdicated due to the mutiny of Aranjuez and gave the throne to his son, Ferdinand VII. Feeling that he was forced to abdicate, Charles IV requested that Napoleon restore him to power. Napoleon helped remove Ferdinand VII from power, but did not return the crown to the former king: instead, he crowned his own brother Joseph Bonaparte, as the new Spanish King. This whole process is known as the Abdications of Bayonne. Joseph's designation found severe resistance in Spain, and the Junta of Seville took power in the absence of the King. Until then, Spain had been an ally of France against Britain, but at this point the Spanish resistance changed sides and allied with Britain against France. The Junta of Seville was eventually defeated as well, being replaced by another one located in Cádiz.