Final answer:
When Napoleon replaced the Spanish king with his brother Joseph, it led to the Peninsular War, where the Spanish and their British allies fought against the French.
Step-by-step explanation:
When Napoleon replaced the Spanish king with his brother Joseph, it led to a series of events known as the Peninsular War (1808-1814). Napoleon turned on Spain after using them to support his invasion of Portugal. As a result, uprisings occurred throughout Spain, and the Spanish, along with their British allies, fought against the French. Guerrilla warfare and increased Spanish nationalism played a significant role in the war.