(covers information from several alternate timelines)
The position of acting captain was bestowed upon an officer or another individual aboard a starship when the ship's regular commanding officer was unable to command for an extended period of time. This person was usually the first officer, and then continued down the ranks until someone was both physically and psychologically able to command.
In 2266, with Captain James T. Kirk being detained by the colony's staff on Tantalus V, Spock was the acting captain of the Enterprise and referred to himself as such in the ship's log. (TOS: "Dagger of the Mind")
While under the influence of the polywater intoxication, Wesley Crusher deemed himself "acting captain" of the USS Enterprise-D in 2364 after commandeering the ship from engineering. (TNG: "The Naked Now")
Aboard the Silver Blood USS Voyager, its copy of Ensign Harry Kim assumed command of the starship as the highest ranking surviving officer, after his own senior officers had dissolved. (VOY: "Course: Oblivion")
In an alternate reality 2233, Lieutenant commander George Kirk, first officer of the USS Kelvin became acting captain of that vessel after Captain Richard Robau was forced to leave the ship and was subsequently killed. Captain Christopher Pike, who later wrote a disseration on the incident noted that Kirk was captain of a starship for a mere twelve minutes but saved the lives of the eight hundred crewmembers aboard the ship.
In 2258, in the same reality, Captain Pike, now commander of the USS Enterprise appointed Commander Spock acting captain and George Kirk's son, Lieutenant Kirk first officer when Pike left the ship to confront Nero. Subsequently, Kirk proved that Spock was unable to perform his duties and then Kirk himself was made acting captain. After everything was over, Kirk was promoted to the rank of captain and made the actual captain of the ship. (Star Trek)