Generally, the captain is the commander of a vessel/ship.
On an aircraft, the captain is the pilot in command (PIC), which is the person in the cockpit sitting on the left with 4 stripes on their shoulder epaulets, in a configuration when there is more than one person in the flight crew.
The captain is legally in charge of everything and everyone on the plane while in the air, but does not necessarily need to have control of the plane at all times, though the captain will be held primarily responsible for anything that goes wrong.
On a ship, in a similar fashion, the captain is the senior person usually, and they are lawfully in command of its operation.
See also: First Officer.