He was promoted to lieutenant-general on 25 April 1808, and in June was given command of 9,000 men set to invade revolutionary Spanish America. But in 1807, Napoleon had invaded Portugal, via Spain, intent on preventing its continued trade with Britain and replacing the Spanish royal family with his own brother, Joseph Bonaparte, in May 1808. In Madrid, the people attempted a rebellion against the French occupation which spread across Spain resulting in mass executions in reprisal, leading both the Portuguese and Spanish "juntas" (local administrations) to call on British support.