The Spanish army was stretched as it fought Napoleon's forces because of a lack of supplies and too many untrained recruits, but at Bailén in June 1808, the Spanish army inflicted the first major defeat suffered by a Napoleonic army; this resulted in the collapse of French power in Spain. Napoleon took personal charge and with fresh forces reconquered Spain in a matter of months, defeating the Spanish and British armies in a brilliant campaign of encirclement. After this the Spanish armies lost every battle they fought against the French imperial forces but were never annihilated; after battles they would retreat into the mountains to regroup and launch new attacks and raids. Guerrilla forces sprang up all over the country and, with the army, tied down huge numbers of Napoleon's troops, making it difficult to sustain concentrated attacks on enemy forces. The attacks and raids of the Spanish army and guerrillas became a massive drain on Napoleon's military and economic resources. In this war, Spain was aided by the British and Portuguese, led by the Duke of Wellington. The Duke of Wellington fought Napoleon's forces in the Peninsular War, with Joseph Bonaparte playing a minor role as king at Madrid. The brutal war was one of the first guerrilla wars in modern Western history. French supply lines stretching across Spain were mauled repeatedly by the Spanish armies and guerrilla forces; thereafter, Napoleon's armies were never able to control much of the country. The war fluctuated, with Wellington spending several years behind his fortresses in Portugal while launching occasional campaigns into Spain.