The dictator in ancient Rome was an emergency magistrate, a man allowed to serve the Roman state and have more power for up to six months. The Roman senate designated one of the consuls to nominate the dictator, who would then appoint a Master of the Horse (magister equitum) to serve as his deputy. The designated consul could not appoint himself, but could appoint his colleague, who could then appoint him as Master of the Horse; this sometimes happened. The dictator had all the powers of the two consuls combined in a single individual, and also exercised within the city the full "imperium" exercised normally by them only outside. He was normally appointed to deal with a military emergency, but there were also cases of other reasons, including religious ritual.
Originally, he was a constitutional figure, but as time went on, culminating with the dictatorship of Sulla, the office became increasingly similar to modern dictatorships. Julius Caesar was appointed as dictator for ten years, and then for life (which turned out to be shorter). After Caesar was killed and Augustus ascended the "throne", no one held the title in Rome afterwards.
The dictator was considered to be a constitutional magistrate and did not have the sense of modern dictatorship which is known nowadays, that of an unconstitutional ruler.