Vice Admiral Sir David Steel, who was the formal representative of the UK's King Charles in Gibraltar, said farewell to local leaders and the general public.
Beforehand, the Royal Gibraltar Regiment and essential services personnel took part in a parade near The Convent, the governor's official residence. In recognition of his naval career, Royal Navy personnel provided the ceremonial Convent Guard. After a royal salute, the governor inspected the personnel on parade and, following a second royal salute, handed over the keys to the Port Sergeant.
On his Main Street walk, Sir David stopped in the courts and the Cathedral as well as Parliament and City Hall to say farewell to leaders there. A 17-gun salute was then fired by the Royal Gibraltar Regiment as Sir David stepped into a British Airways aircraft going to London.
Chief Minister of Gibraltar Fabian Picardo said of Sir David:
"Yours is a big heart that you have opened up to us and to our small but proud nation."
Lieutenant General Sir Ben Bathurst has been appointed Govenor of Gibraltar and will take up his place next month.