From the Clan Gregor, MacGregor was an officer in the British Army from 1803 to 1810; he served in the Peninsular War. He joined the republican side in the Venezuelan War of Independence in 1812, quickly became a general and, over the next four years, operated against the Spanish on behalf of both Venezuela and its neighbour New Granada. His successes included a difficult month-long fighting retreat through northern Venezuela in 1816. He captured Amelia Island in 1817 under a mandate from revolutionary agents to conquer Florida from the Spanish, and there proclaimed a short-lived "Republic of the Floridas". He then oversaw two calamitous operations in New Granada during 1819 that each ended with his abandoning British volunteer troops under his command.