Among the early blows struck for independence was a rebellion in the town of Olhão. On 16 June 1808, the townsfolk — armed with little more than ancient swords, spears, and stones — attacked and captured the local French garrison. It's said that a party of local men then set sail from Olhão all the way to Brazil, without maps or navigational aids, to tell the king of the insurrection. The real battle, however, was waged under the leadership of the Duke of Wellington, whose coalition forces expelled the French after two years of bitter fighting. The war left Portugal further weakened, and in 1822 its major empire outpost, Brazil, declared independence. At the same time, a dispute over the crown continually raged between Pedro IV, the absentee monarch who preferred to reign as Emperor of Brazil rather than return to Portugal, and his brother Miguel. The power struggle, with strong overtones of absolutism versus liberalism, excited the interest and intervention of other powers. With British help, Pedro defeated Miguel off Cape St. Vincent in 1833, and his expeditionary force marched to Lisbon. Pedro took the throne, though armed struggle continued for months and the lingering bitterness long after that. By 1892 Portugal, racked by wars and the continuing expense of maintaining its African colonies (including those of Mozambique and Angola), declared itself bankrupt. The seeds of discontent with absolutist rule were sown. Kingdom's End Bloodshed would haunt the remaining years of the Portuguese monarchy. On 1 February 1908, the royal family was riding in an open carriage along the Lisbon river front plaza, Terreiro do Paço, when an assassin opened fire and killed King Carlos and the heir to the throne, Prince Luis Filipe. The prince's younger brother, Prince Manuel, was also hit, but he survived and was thus propelled to the throne at the tender age of 19. Amid republican agitation, a surprise uprising led by elements within the armed forces deposed Manuel in 1910. Having ruled for less than three years, Manuel died in exile in 1932 in England. The sudden end of more than seven centuries of monarchy brought confusion and crisis to the country. Presidents and prime ministers were ushered into and out of office an unbelievable 45 times between 1910 and 1926, until a military revolution suspended Portugal's problematic democracy. 
Why did Brazil declare independence when it did?
Portugal was bankrupt