He was born in Pontevedra, Spain,[2] into a prominent Irish-Spanish family, though his naval records state his origin as Irish.
His father was a Spanish Army brigadier-general and colonel of the Irish Regiment of Irlanda, and his mother a lady-in-waiting to the royal household.
[4][5] His grandfather was born in Dublin and his grandmother was from Cork, and they fled to Spain to escape from religious persecution in Ireland.
MacDonnell was swiftly promoted to infantry lieutenant in 1769 and then advanced to the rank of captain in 1774, before requesting a transfer to the Spanish Navy.
In July 1776, he joined the Spanish Navy as a sub-lieutenant and was assigned to the frigate Gaviota as part of a mission against the Algerians in the squadron of Captain Felix de Tejada.
In November Carmen and its support ships fought and burned two Ottoman Algeria xebecs in Melilla cove.
The Spanish never made this interception but on 11 September the squadron spotted a lone British ship off Terceira Island in the Azores.
Santa Maria Magdalena and another frigate gave chase, but the British ship escaped as nightfall arrived.
[9][10] On 15 August 1779, Santa Maria Magdalena captured the British 10-gun privateer Duke Of Cornwall off Cape St Vincent by disguising herself as a merchant ship.
In April 1781, he boarded the 74-gun ship San Gabriel, and participated in the Siege of Pensacola, where he went ashore with a detachment of marines and was wounded in action.
[15] On 26 May, he took command of the sloop Santa Ana and transferred 400 soldiers from Trujillo, Colón, to the River Tinto in Honduras and other British settlements along that coast.
[2][5] He was in the admiralty in Madrid for first nine months of 1784 before taking brief command of the 74-gun Santo Domingo and sailing it to Ferrol to be decommissioned.
[16] MacDonnell returned to Cadiz in July 1787 and was appointed to the position of port captain in autumn of that year briefly, and reappointed from May 1788 to March 1789.
[4] During the summer of 1789 MacDonnell joined the Swedish Navy to take part in the Russo-Swedish War and was assigned command of the hemmema Oden with Måns von Rosenstein.
[5] In July 1791, he returned to Spain, taking command of the 68/64-gun San Felipe Apostol conducting operations off the coast of Morocco until December.
[5] MacDonnell was captain of the 60-gun Astuto from 5 May to 31 August 1793, and sailed with the a fleet of 24 ships under the command of Don Francisco De Borja, in the Campaign of Sardinia.
Heavily outnumbered the French garrison of 800 men and 400 sailors surrendered without a battle, and the 36-gun frigate Hélène was captured.
The plan submitted to the Spanish Admiralty for a full-scale war and invasion of the United States, involving naval and ground battles.
Before the battle itself, a war council meeting of the fourteen leading Franco-Spanish admirals and commodores was held on Pierre-Charles Villeneuve's ship in Cadiz's port.
On 22 October, the day after the battle, a council of war meeting of senior naval officers was held in Cadiz, where the surviving ships had harbored.
As the only senior officer remaining, MacDonnell was given command of the squadron chosen for this task along with French commodore Julien Cosmao.
[26] The following morning on 23 October, at 9:30am the sortie began and five ships of the line (Pluton, Indomptable, Neptune, Rayo and San Francisco de Asis), alongside five frigates and two brigs (Cornélie, Thémis, Hortense, Rhin, Hermione, Furet and Argus), set out to sea.
Santa Ana, with Vice-Admiral Ignacio Álava onboard, reached Cadiz safely, while the crews of San Francisco de Asis and Neptuno were also rescued.
MacDonnell was able to write a full report to Admiral Gravina while on board Donegal indicating he was afforded cordial treatment and facilities.
MacDonnell lowered the Spanish flag to surrender after the first cannon shot, and then threw the ship's secret signals book overboard tied to a cannonball.
It coincidentally was the French frigate that Irish revolutionary Wolfe Tone was captured on off the coast of Ireland, having been renamed.
His first task was to sail out to the British fleet under Admiral Collingwood to declare they were about to attack the French and to seek an alliance with Britain.
After taking the French ships he boarded the flagship of British admiral John Child Purvis, general commander of the squadron that blockaded the city, trying to cease hostilities between Spain and Great Britain.
In this he was so successful that the British general Sir John Moore, offered to support MacDonnell's appointment as the Junta's ambassador in London; but MacDonnell refused saying, "to have accepted a diplomatic post when there was a general call to arms in my country, would not have been in keeping with the dignity and character of a high-ranking officer."