The command of a ship is most often given to the naval rank (equivalent to a commissioned officer between commander (OF-4) and commodore or rear admiral (OF-6)). The Polish Navy is, however, a notable exception naval captain in position of Lieutenant or Captain Lieutenant and OF-5 rank being a "commander" (komandor). The naval rank should not be confused with the army, air force or marine rank of captain, which has a NATO code of OF-2.
Any naval officer who commands a ship is addressed as "captain" while aboard that ship, by naval custom. A naval officer with the rank of captain traveling aboard a vessel he does not command is either never referred to by rank or, in some navies, is addressed as Commodore to avoid confusion with the ship's commander. Navy personnel travelling on the ship who outrank its commander cannot override the commander in matters of directing the ship's operations.
Throughout the Middle Ages the Navy was an ad-hoc group of ships contracted for the duration of a given conflict and disbanded thereafter. The ship's Master, who would command the ship during peacetime, would also remain in control of all things nautical during wartime. The Captain was merely the commander of the embarked infantry contingent upon the ship who, with the help of his lieutenants, would act as the agent of the king - and hence de facto commander - while the ship was contracted with the Navy. During Tudor times, the title of Captain began to refer to the commander of a ship of the Royal Navy, once that organization became established and maintained a standing fleet.
As a matter of etiquette in the U.S. Navy there is only one captain aboard a vessel. If a Marine Corps captain is at the officer's mess, he or she is given the higher courtesy title of major to avoid confusion with the commander of the ship.
Captains with sea commands generally command ships of cruiser size or larger, while Naval Aviator and Naval Flight Officer Captains in the U.S. Navy command aircraft carriers, large-deck amphibious assault ships, carrier air wings, maritime patrol air wings and functional and specialized air wings and air groups. The more senior the officer, the larger the ship, but ship commanders do not normally hold a higher rank than captain.
Rear Admirals will normally embark on large capital ships such as aircraft carriers, which will function as the flagship for their strike group or battle group, but a Captain will retain command of the actual ship. Even when a senior officer who is in the ship's captain's chain of command is present, all orders are given through the captain as a courtesy. Many captains hold shore commands and staff positions afloat and ashore.
The following articles deal with the rank of captain as it is used in various navies.