The electoral commission declared Ghazouani winner late on Saturday with 52% of the vote. His nearest rival, anti-slavery campaigner Biram Dah Abeid, came second with 18.58%, while third place candidate Mohamed Ould Boubacar, who is backed by Mauritania's biggest Islamist party, got 17.85%.
The election was the first in the sparsely populated Saharan nation's history, since independence from France in 1960, to choose a successor to a democratically elected president.
None of the three remaining candidates got more than 10%.
Ghazouani has campaigned on continuing economic and security progress made under outgoing president Mohamed Ould Abdel Aziz, who took the helm in a 2008 coup, then won elections in 2009 and 2014.
Under the leadership of the 62-year-old president, the economy has grown and will receive an extra boost when a large offshore gas field starts producing early next decade.
Hours earlier government spokesman Sidi Mohamed Ould Maham had declared Ghazouani "president-elect" at a news conference, and opposition candidates represented by Abeid said they would contest the results.
"This seems like a coup d'etat," Ghazouani's nearest rival, Biram Dah Abeid, representing himself and the other opposition leaders, said. "We are united and will lead the contestation (of the results)."
The election has been largely peaceful, apart from in some Riyadh, Elmina, and Sebkha regions of Nouakchott, where earlier on Sunday protesters burned tires and trash before police dispersed them.
Abdel Aziz surprised many of his compatriots and international observers by stepping aside after serving the maximum two five-year elected terms in Mauritania, a country of fewer than 5 million people comprising a large chunk of the western Sahara Desert.
His decision bucked a trend in which African leaders, including in Rwanda and Congo Republic, have changed or abolished term limits to cling to power.
Despite his economic record, Abdel Aziz has been criticized for not facing up to Mauritania's most searing injustice: the persistence of slavery. Tens of thousands of black Mauritanians still live as domestic slaves, rights groups say, usually to lighter-skinned masters of Arab or Berber descent.
That is despite the practice being abolished in 1981 and criminalized in 2007, the year before he took power.
He has made pronouncements denying slavery is widespread.
Abeid, himself a descendant of slaves, had campaigned partly on this platform. He and other opposition leaders also sought to tap into youth anger at high unemployment.