Mr Yameen had 51.3% of the vote compared with 48.6% for ex-President Mohamed Nasheed, with 98% of ballots counted, the Election Commission said.
Mr Nasheed had won 47% in the first round this month, just short of the 50% needed for outright victory, in an election process mired in controversy.
Mr Yameen is half-brother to Maumoon Abdul Gayoom, who ruled for 30 years.
Imad Masood, a spokesman for outgoing President Mohamed Waheed, told Reuters there were "four more boxes yet to be counted, but they won't make any difference to the final results".
There have been months of legal and political wrangling over the election, causing concern among foreign diplomats.
One result was annulled and two votes cancelled by the courts.
Mr Nasheed had been seeking to regain power after he was forced to resign in 2012.