Commander

Commander was a common military rank or title, and was used in several different ways throughout.

Galactic Empire
In the Imperial Navy, a Commander was a command-level rank given authority over a wide area of operations and personnel. Aboard a Star Destroyer, a Commander typically managed a major sector of the warship's operations. A Commander could also be the Star Destroyer's Executive Officer or Third Officer.

In most cases, Commanders were the closet aides to the Captain. On a smaller vessel, a Commander could be the Commanding Officer, or Executive Officer, depending on the situation.

New Republic
In the New Republic Starfleet, commanders were often heads of departments (such as engineering, medical, logistics, etc.), senior staff underneath a Captain, or the captain of ship itself if said ship was light cruiser scale or smaller, or a support ship.