In 1807 France tried to force Portugal to join the Continental System, a commercial embargo against Britain. When the Portuguese Prince Regent, John refused to join, Napoleon sent General Junot to invade Portugal in 1807, resulting in the six year Peninsular War. The war weakened the French Empire's military, particularly after Spanish forces and civilians rebelled against France after Napoleon overthrew the Spanish king. After the French defeat at the Battle of Bailén, Napoleon took command of the French forces, defeating the Spanish armies before returning to France. Jean-de-Dieu Soult drove the British out of Spain in the Battle of Corunna in January 1809.