MacGregor was introduced to Maria Bowater, the daughter of a Royal Navy admiral, around 1804. Maria commanded a substantial dowry and, apart from her by-now-deceased father, was related to two generals, a member of parliament and the botanist Aylmer Bourke Lambert. Gregor and Maria married at St Margaret's Church, Westminster in June 1805 and set up home in London, at the residence of the bride's aunt. Two months later, having rejoined the 57th Foot in Gibraltar, MacGregor bought the rank of captain for about £900, choosing not to wait the seven years such a promotion might take without purchase. The 57th Foot remained in Gibraltar between 1805 and 1809. During this time MacGregor developed an obsession with dress, rank insignia and medals that made him unpopular in the regiment; he forbade any enlisted man or non-commissioned officer to leave his quarters in anything less than full dress uniform.