In 1809, with Napoleon and his best troops bogged down in Spain, Austria decided to try to get revenge for her humiliation at Austerlitz three years before. Archduke Charles led an invasion of France's ally Bavaria, but Napoleon raised fresh troops and transformed the strategic situation in four days of hard fighting along the Danube. But having taken Vienna, Napoleon's overconfidence led to a desperate battle at Aspern-Essling, resulting in his first major defeat as Emperor, and the death of his closest friend.