The Portuguese armed forces had a long tradition dating back to Portugal's founding in the 12th century. Portuguese militia units under King Afonso Henriques secured Portugal's independence from the Kingdom of Leon and continued raiding the Moorish realms throughout the 12th to 15th century. When Portugal developed her trading links with West Africa in the 15th century she eventually became the chief European trading partner with West Africa and tried to act as middleman for goods travelling between the Mediterranean and Atlantic trade theatres. In the early 16th century Portuguese ships trvalled further than ever before, sailing around the bottom of Africa and South America and even around the entire world - using Royal funds to rent trading posts right across Africa, India, and the Far East. Portugal also lucked into large, underpopulated areas in South America (Brazil).
Portugal's chief ally in this period was England and her chief rival was the personal union of Castile-León-Aragon ('Spain'). In 1580, King Sebastian and most of the Portuguese nobility attempted to wage an honest-to-goodness Crusade against the Morroccans, and were completely butchered. Sebastian died without an heir, so his closest living relative - who was in Spain - took the throne. Philip II of Castile-León, Philip I of Aragon, and Philip I of Portugal (all the same person) then ruled a united Iberian peninsula for the first time since the Romans.
However, the Portuguese nobility were not happy with the personal union. They keenly felt the neglect of the Portuguese language in the courts of Philip III and Philip IV, resented the way that many high posts in the Portuguese government went to Castilians, and generally felt that they would be much richer if they had a country which was politically neutral and so didn't have to fight so many wars and therefore tax them so much. In the middle of Portugal-Castile-León-Aragon's Eighty Years' War against Dutch rebels and Thirty Years' War against the Protestant countries of the Holy Roman Empire in the 1640s, several Portuguese nobles took the opportunity to revolt and launched constant raiding expeditions into Castile. With the government heavily committed overseas and later decisively defeated in and completely bankrupted (several times!) by both wars, Philip IV eventually had no choice but to let Portugal have its independence. They had to contend with their rivals, the Spanish, in different wars.
Later, the Portuguese military went on to participate in the War of the Spanish Succession and three more wars with Spain.
In the Peninsular War against Napoleon's France the Portuguese military were forced to abandon their entire country to the French and fall back to a national redoubt in the immediate area around the capital of Lisbon which could be supplied by sea - the Lines of Torres Vedras proved a remarkable defence against the French troops. With massive British food aid and a large British military garisson, the redoubt managed to hold out for a year before the British went on to drive the French completely out of the Iberian peninsula with the help of Spanish and Portuguese partisans.
Later, the Portuguese military were involved with both sides in the Liberal Wars of 1828-34, a civil war between the brothers Pedro IV (who by then, was the ex-ruler of Brazil), and Miguel I, who was the king of Portugal at that time. Pedro's daughter, Queen Maria da Glória, eventually won the war.
By the turn of the 20th century, the Portuguese military helped instigate a coup that ended the Portuguese Monarchy in 1910. The Portuguese later joined World War I on the Allied side, fighting in Africa (its colonies were threatened by the German general Lettow-Vorbeck) and in Europe.
Under Premier Salazar's rule, the Portuguese sent 18,000 volunteers in the Spanish Civil War on the side of Franco. In 1939, the governments of Salazar and Franco signed the Iberian Pact, ensuring neutrality for both sides in World War II. To ensure the neutrality, foreign policy relied on helping both parties in non compromising ways; namely selling (legally) wolframium to the Axis, and allowing the construction of the Azores air base, possible by the Treaty of Windsor with the United Kingdom, the oldest mutual assistance treaty still active (1386!). The air base was later assigned to the United States and it still stands active (albeit with lesser importance) nowadays.
The Portuguese military since World War II had to contend with African independence movements, as well as the Indian seizing of Goa in 1961, in a conflict that came to be known as the Overseas War or Guerra do Ultramar. However, many leftist military officers were tired of the war and were disillusionednote with Portuguese premier Marcello Caetano, that they, along with left-wing protesters, initiated a revolution in 1974 known as the Carnation Revolution. It also restored Portuguese democracy and eventually the Portuguese military retired from politics.
Although conscription was the rule before, it was abolished in the 2000s. The Portuguese military today is professionalized though there are many complaints of lack of manpower. The country is a founding member of NATO and has participated in missions in places like Kosovo.
The military is composed of the Army, the Navy, the Air Force, and the gendarmerie, the National Republican Guard.
Definitely not to be confused with a Portuguese man o' war, which is a highly venomous jellyfish-like creature (although the Portuguese Navy did operate its namesake, the Portuguese man-of-war, back in the Age of Sail).