Moderate cleric Hassan Rouhani has been elected the president of Iran, the Interior minister has announced.

Mostafa Mohammad-Najjar told a press conference on Saturday that Rouhani had won Iran's presidential election with more than 18 million of the votes.

Najjar said 72 percent of the 50 million eligible Iranians had turned out to vote, and that Rouhani had secured just over the 50 percent of the vote needed to avoid a run-off.

His closest rival, Tehran mayor Mohammad Baqer Qalibaf, garnered six million votes.

Al Jazeera's Soraya Lenni, reporting from Tehran, said that all Rouhani needed was 50 percent plus one vote in order to avoid a run-off.

"Everybody was predicting a very close race and that this would end in a run-off between Rouhani and Qalibaf," our correspondent said.

She said that everything had run quite smoothly on election day.

"There were long lines at polling stations, but everything was quite orderly," she added.

Mahmoud Ahmadinejad still has about a month and a half of his presidency left and then Rouhani will be sworn in.