Commander is a military rank, the equivalent of which is used by the service organizations of many civilizations. As a traditional naval grade, commander is the second most senior line officer rank, falling between Captain and Lieutenant Commander in hierarchy, usually given to executive officers and department heads, aides de camp, or the skippers of smaller vessels or leaders of other contingents of officers, such as on a Starbase. Proper naval parlance says that, even if a naval vessel is commanded by an officer whose rank is commander, that officer is still able to be referred to as a captain while on the deck of their own vessel. Commander is equivalent to the infantry rank of Lieutenant colonel, or the subcommander grade used by the Romulan Star Empire and the Vulcan High Command. On Earth, the rank of Commander originated in the 18th Century Royal Navy of the United Kingdom as "master and commander." In the 19th Century the rank was shortened to "commander" and continued unchanged in that form through at least the 24th.
In Starfleet, a prerequisite to becoming a commander is by taking the Bridge Officer's Test. As commanders prove their leadership ability over time, they are considered for the difficult and highly competitive promotion to Captain.