Since the capture of the Rock in 1704, the Keys of Gibraltar have symbolised the possession of the Fortress by Great Britain.  The Keys have come to be regarded as the seals of office of the Governor and as such are handed over from one Governor to the next.

During the Great Siege (1779-1783) the Governor (General Elliot, later created Baron Heathfield of Gibraltar for his heroic defence of the Rock), wore the Keys at his belt constantly except when he handed them to the Port Sergeant.  As the Sunset Gun was fired, the Port Sergeant, accompanied by an armed escort, would lock the gates in the North Wall at Landport, Waterport and Chatham Wicket.  The Keys would be returned to the Governor.  The following morning  the Port Sergeant would collect the keys again, reopen the gates and hand back the keys to the Governor for safe keeping.

After peace was restored in 1783, drums and fifes accompanied the Port Sergeant and his escort to warn aliens to leave the Rock before the gates were closed.  This procedure was carried out each evening without interruption for approximately 140 years until discontinued after the First World War.  The event was then revived as a ceremony in 1933.  The ceremony is now performed once a year by the Royal Gibraltar Regiment and re-enacted every Saturday morning at midday by the Gibraltar Re-enactment Association.