A harbourmaster (or harbormaster, see spelling differences) is an official responsible for enforcing the regulations of a particular harbour or port, in order to ensure the safety of navigation, the security of the harbour and the correct operation of the port facilities.
An example of this is the team of harbourmasters employed by the Port of London Authority who are empowered to undertake an enforcement role.
Actions that a harbourmaster may investigate include criminal acts, immigration, customs and excise, maritime and river safety and environmental and pollution issues.
The police, customs, coastguard or immigration authorities will take over the handling of any offenders or incident once informed by the harbourmaster.
In the United Kingdom and Canada, a person that is appointed to superintend a dockyard port and ensures the port is secure for civilian and military shipping is known as a King's Harbour Master (or Queen's Harbour Master during the reign of a queen).