Iran’s state television has declared incumbent President Hassan Rouhani the winner of the country’s presidential election, giving him a second four-year term to see out his agenda calling for greater freedoms and outreach to the wider world.

State TV offered its congratulations in a brief statement Saturday, based on vote tallies.

The 68-year-old has come to embody more liberal and reform-minded Iranians’ hopes for greater political freedom at home and better relations with the outside world. Preliminary vote tallies earlier had Rouhani ahead with 22.8 million votes, out of 38.9 million counted so far. Officials say more than 40 million people voted.

In 2013, Rouhani won the presidential election with nearly 51 percent of the vote. Turnout for that vote was 73 percent.

As Rouhani appeared close to victory, some female drivers held out the V for victory sign and flashed their car lights on highways in Tehran’s affluent north.

Iran’s president is the second-most powerful figure within Iran’s political system. He is subordinate to the supreme leader, who is chosen by a clerical panel and has the ultimate say over all matters of state.

Election officials repeatedly extended voting hours until midnight to accommodate long lines of voters, some of whom said they waited hours to cast their ballots. Analysts have said a higher turnout would likely benefit Rouhani.

Friday’s vote was largely a referendum on Rouhani’s more moderate political policies, which paved the way for the landmark 2015 nuclear deal that won Iran relief from some sanctions in exchange for curbs on its nuclear program.