Typically, Commanding Officers hold the rank of Captain or Commander, though at times it may be necessary for officers of higher or lower ranks to take command. Regardless of rank, the ship's commanding officer is referred to as 'the Captain'. Ultimately responsible for the ship and crew, the Commanding Officer is the most senior officer aboard a vessel or starbase. S/he is responsible for carrying out the orders of Starfleet, and for representing both Starfleet and the Federation.
A Ship's Captain is responsible for its safe and efficient operation, including cargo operations, navigation, crew management and ensuring that the vessel complies with local and interstellar laws, as well as Starfleet and Federation policies and standing orders.
Captains of starships, often located hundreds of light years away from and out of communications with higher authority, must be able to function autonomously and make independent command decisions affecting Federation policy and countless lives. Accordingly, few Starfleet officers ever gain the captaincy of a starship, the result of decades of sustained excellence as a Starfleet leader.