Iranian state TV announced Rouhani's win that will see him serve a second term as president, with a convincing 57 percent of the vote.
By crossing the 50 percent mark, it means Rouhani will not have to face his conservative challenger in a second round of voting with Raisi getting just 38.5 percent of the vote.
Turnout reached 73 percent, which helped ensure Rouhani can continue his reforms for another four years.
"I congratulate the great victory of the Iranian nation in creating a huge and memorable epic in the continuation of the path of 'wisdom and hope'," tweeted Vice President Eshaq Jahangiri.
Iranian specialists believe that Rouhani's win marks a shift away from the populism of Raisi into more global and engaging forms of government.
"Rouhani's vote, particularly in rural areas, shows that Iranian people no longer believe in economic populism and radical change," said Ali Vaez, Iran analyst for the International Crisis Group told AFP.
"They have the maturity to understand that the solution to their country's predicaments are in competent management of the economy and moderation in international relations."
Rouhani's first term was marked agreeing a deal with world powers that would see Iran curb its nuclear ambitions in return for sanctions relief.
The deal saw relations between the US and Iran improve to their best in decades, although the election of the most combatitive Donald Trump threatened the gains of moderate Rouhani.
The centrist president won the approval of former reformist Present Mohammed Khatami, who urged liberals to vote for Rouhani.
The New ArabComments