(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")
On several occasions from 2372 until 2375, Lieutenant Commanders Worf and Jadzia Dax were made acting captain of the USS Defiant for missions in the Gamma Quadrant and during the Dominion War. Captain Benjamin Sisko was the commander of DS9, which during the war was the headquarters for the Federation Alliance, and would often demand his close attention. As such would entrust to his most senior Starfleet officers command of the ship and its crew. (DS9: "Rejoined", "Paradise Lost", "Call to Arms", "Behind the Lines")
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 dissertion 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 of the USS Enterprise appointed Commander Spock acting captain and George Kirk's son, Lieutenant Kirk as 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 given command of the ship. (Star Trek)
Later, in 2259, Kirk placed Hikaru Sulu in charge when he and other members of his crew flew a K'normian trading ship to Qo'noS to apprehend John Harrison, a move which Leonard McCoy questioned, saying, "You just sat that man down at a high-stakes poker game with no cards and told him to bluff." Kirk rebuffed his concerns.
As acting captain, Sulu ordered the refueling and preparation of the K'normian ship for Kirk and his team. He also delivered an ultimatum to Harrison that impressed McCoy and caused the doctor to revise his earlier opinion.
When Kirk was aboard the USS Vengeance, and the USS Enterprise was falling towards Earth, Spock, in the role of acting captain, ordered the entire crew to evacuate the ship while he remained behind to ensure their safety until they did. Sulu and the rest of the bridge crew declined, strapping themselves in. (Star Trek Into Darkness)