In a briefing for reporters, interior ministry official Ali Asghar Ahmadi outlined a similar proportion of votes received.
"It's over, Rouhani is the winner," the source said on condition of anonymity.
The pragmatist Rouhani won 21.6 million votes in Friday's hard-fought contest, compared to 14 million for Raisi, with 37 million votes counted, the source said, adding about four million more votes were still to be tallied.
The interior ministry official said that with 25 million ballots certified by the authorities so far, Rouhani won 14.619 million and Raisi gained 10.125 million.
He said 40 million votes had been cast, indicating a turnout of about 70 percent, roughly similar to the showing in 2013 elections when Rouhani swept into office in a landslide victory
Ahmadi said final results would be announced later on Saturday.
The big turnout appeared to have favoured Rouhani, whose backers' main worry has been apathy among reformist-leaning voters disappointed with the slow pace of change.
Rouhani, 68, who took office promising to open Iran to the world and give its citizens more freedom at home, faced an unexpectedly strong challenge from Raisi, a protege of supreme leader Ali Khamenei.
The election is important "for Iran's future role in the region and the world", Rouhani, who struck a deal with world powers two years ago to curb Iran's nuclear programme in return for the lifting of most economic sanctions, said after voting.
Raisi, 56, has accused Rouhani of mismanaging the economy and has travelled to poor areas, speaking at rallies pledging more welfare benefits and jobs.
He is believed to have the backing of the powerful Revolutionary Guards security force, as well as the tacit support of Khamenei, whose powers outrank those of the elected president but who normally steers clear of day-to-day politics.
"I respect the outcome of the vote of the people and the result will be respected by me and all the people," Raisi said after voting, according to the semi-official Fars news agency.
However, Raisi later appeared at the Ministry of Interior in Tehran on Friday and complained of a shortage of ballot sheets at many polling stations, according to Fars. More ballot sheets were subsequently sent out, the agency reported.
The Guards and other hardliners had hoped that a win for Raisi would have given them an opportunity to safeguard economic and political power they see as jeopardised by the lifting of sanctions and opening of the country to foreign investment.
Rouhani has urged the Guards not to meddle in the vote, a warning that reflects the political tension. Suspicions that the Guards and the Basij militia under their control falsified voting results in favour of hardliner Mahmoud Ahmadinejad led to eight months of nationwide protests in 2009, which were violently suppressed.
For ordinary Iranians, the election presents a stark choice between competing visions of the country.
Rouhani, known for decades as a mild-mannered establishment insider rather than a gung-ho reformer, has taken on the mantle of the reform camp in recent weeks, with fiery campaign speeches that attacked the human rights records of his opponents.
"I voted for Rouhani to prevent Raisi's victory. I don't want a hardliner to be my president," said Ziba Ghomeyshi in Tehran. "I waited in the line for five hours to cast my vote."
Many pro-reform voters are still lukewarm Rouhani supporters, disappointed with his failure to make broader changes during his first term. But they were anxious to keep out Raisi, who they see as representing the security state at its most fearsome: in the 1980s he was one of four judges who sentenced thousands of political prisoners to death.
"I like his (Rouhani) detente policy with the world. I know he is not a reformist, but who cares? What matters is that he is not Raisi," employee Yousef Ghaemi, 43, said by phone in the western city of Kermanshah.
For conservatives, the election represented a chance to restore the values of the 1979 revolution, which requires elected officials to be subordinate to the Shi'ite Muslim clergy and supreme leader.
"I voted for Raisi because he is a follower of Imam Khamenei. He will not confront the leader if elected. He will protect our Islamic identity," said Mehran Fardoust, 36, a shopkeeper near the Imam Reza Shrine in the holy city of Mashhad, Raisi's home town.
Despite the removal of nuclear-related sanctions in 2016, lingering unilateral U.S. sanctions that target Iran's record on human rights and terrorism have kept foreign companies wary of investing, limiting the economic benefits so far.
Raisi has focused his campaign on the economy, visiting rural areas and villages and promising housing, jobs and more welfare benefits, a message which could have resonated with millions of poor voters angry at the Tehran elite.
(Additional reporting by Bozorgmehr Sharafedin, Writing by William Maclean; Editing by Samia Nakhoul)
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)