The Iberian conflict began when Portugal continued trade with Britain despite French restrictions. When Spain failed to maintain the Continental System, the uneasy Spanish alliance with France ended in all but name. French troops gradually encroached on Spanish territory until they occupied Madrid, and installed a client monarchy. This provoked an explosion of popular rebellions across Spain. Heavy British involvement soon followed.