Her Majesty's Ship

HMS is an acronym (contraction) of Her Majesty's Ship. It refers to ships of the Royal Navy. It is the official prefix of Royal Navy ship names since 1789. Versions of HMS are used in those Commonwealth countries where the British monarch is still the head of state. So, for example, HMNZS is the prefix for the Royal New Zealand Navy.
There are some similar designations. RMS designates a ship which officially transports mail for the United Kingdom. Other countries with monarchs use the same kind of system, and almost all countries have a prefix system for their ships.