João de Almeida de Melo e Castro, 5th Count of Galveias

D. João de Almeida de Melo e Castro, 5th Count of Galveias (23 January 1756 – 18 January 1814) was a Portuguese nobleman, diplomat, and politician. He held a number of important diplomatic posts, before becoming an influential politician.

Diplomatic career
He joined the diplomatic service, filling the posts of Minister of Portugal in The Hague (1782–1788), Rome (1788–1790), and London (1792–1801). When in the Court of St James's, in the troubled times of the French Revolution and later the Napoleonic Consulate, Melo e Castro had the thorny mission of keeping neutral as Portugal wavered between France and the United Kingdom.

Political career
In 1801, Melo e Castro was named Secretary of State of Foreign Affairs and War by John, Prince Regent, with the demanding task of reorganising the Portuguese Army, badly ravaged following the War of the Oranges, due to the imminent threat of the European conflict. When Portugal and France re-established diplomatic relations following the signing of the Treaty of Amiens and the brief interval of peace in Europe, Jean Lannes was sent as the French ambassador to Portugal: he soon clashed with Melo e Castro (who he described as "a man of the English" ) and demanded his dismissal (a demand that was soon after endorsed by Napoleon ). Melo e Castro was stripped of his office in August 1803.

After the transfer of the Portuguese court to Brazil, from Rio de Janeiro, Melo e Castro was briefly Acting Secretary of State of the Navy and the Overseas. From 1812 to 1814, he tried to limit the growing British influence over Portugal as Secretary of State of Foreign Affairs and War.

Titles
For his services to the Crown, he was granted the title of Viscount of Lourinhã in 1797 (a title that had originally belonged to a childless uncle, Manuel Bernardo de Melo e Castro) and, later, on 17 December 1808, he succeeded his great-grandfather, André de Melo e Castro as Count of Galveias. João de Almeida de Melo e Castro married Isabel José de Meneses, 5th daughter of the Counts of Cavaleiros, and they had no issue; he was succeeded in the House of Galveias following his death by his younger brother Francisco de Almeida de Melo e Castro.