Between 1766 and 1768, Harvey commanded the sloop off
Scotland but following promotion in 1768 he was again forced to take half-pay on shore for the next eight years, until the
American War of Independence caused a dramatic increase of the size of the Navy. Briefly commanding the sloop , Harvey was soon promoted once more, making
post captain and being given the prime command of , the 60-gun
flagship of
Admiral Robert Duff at
Gibraltar. From 1778 until 1780, Harvey distinguished himself at the
Great Siege of Gibraltar, even commanding there during 1780 in the absence of his senior officer. In 1780,
Panther returned to England and was then attached for a year to
Sir Samuel Hood's fleet in the West Indies. Returning to England early in 1782, Harvey was transferred to the new 64-gun ship and in her returned to the
Mediterranean, again distinguishing himself at the relief of Gibraltar and the subsequent
Battle of Cape Spartel. At the war's conclusion the following year, Harvey retained his active career due to his excellent records and served in several shore appointments, including regulating captain at
Deal and commander of the guardship at
Sheerness. ==French Revolutionary Wars==