In the Navy, the term Captain had two meanings.
Post-Captain was a military rank above Commander and below flag rank. When a Lieutenant was posted as a Commander, he was entitled to wear a Captain's epaulette on one shoulder of his uniform, then when he attained three years in that rank was then entitled to wear the epaulette on both shoulders.
Once one was posted, he was added to the 'Captain's List' noting the seniority of each Captain in the service so that when more than one ship worked together, the Captain most senior was in charge. Rising to Flag ranks was usually by seniority on the Captain's List.
Anyone commanding a naval ship was referred to as 'Captain', regardless of military rank.
- Post Captain at Wikipedia