Captain of the port
To some extent the role of captain of the port is analogous to that of a harbourmaster.
In the Royal Navy, the captain of the port was the officer, usually with the rank of captain, responsible for the day-to-day running of a Naval Dockyard under the authority of the admiral-superintendent. He usually also held the position of Queen's or King's harbourmaster and was directly responsible for the captain's department, which among other things operated the yard craft.
The term was in use from around 1969; prior to this, the equivalent appointment was captain of the dockyard (from around 1903) and, before that, staff captain (dockyard). Their historic predecessors held the appointment of master attendant (which was likewise often combined with that of King's or Queen's harbourmaster) until the second half of the 19th century, when they (in common with other Royal Naval masters) began to be commissioned with the rank of staff captain.
In the United States, captain of the port (COTP) is a title held by a United States Coast Guard officer, usually the commander of a United States Coast Guard sector with the rank of captain (O-6). Captain of the port duties involve enforcing within their respective areas port safety and security and marine environmental protection regulations, including regulations for the protection and security of vessels, harbors, and waterfront facilities; anchorages; security zones; safety zones; regulated navigation areas; deepwater ports; water pollution; and ports and waterways safety.