Nasheed was the clear pre-election favorite but lost his momentum amid long delays to complete the election.
After his victory became apparent, Gayoom told reporters that Maldivians have decided what's best for them and asked the international community to respect their choice.
"It's now time to bring peace, the people have decided. It's now time for development," Gayoom said.
Nasheed conceded the election and said he would not challenge the results.
"This is a very happy day for all of us, we now have an elected president," he said. "We don't want to go to the courts."
The Maldives had failed to elect a president in three attempts since September, raising concerns in the international community that the fledgling democracy may slip back to authoritarian rule.
Nasheed received 45 percent in a Sept. 7 election, but the result was annulled by the Supreme Court after Ibrahim complained that the voters' register contained made up names and those of dead people.
Last month, police stopped a second attempt at holding the election because all the candidates did not accept a new voters' list as the court had mandated.
The court intervened again to change the runoff election date, which had been set for the day after the Nov. 9 vote. It also ordered incumbent President Mohamed Waheed Hassan to continue in office despite the official end of his term on Nov. 11, purportedly to avoid a constitutional void because the country is past the legal deadline to elect and seat a new president.
The European Union, concerned about the return of authoritarian rule, warned that it is considering "appropriate measures" if the Maldives failed to elect a new president Saturday. It said further delays would be seen as attempts to prevent Maldivians from exercising their democratic rights.
U.S. State Department spokeswoman Jen Psaki said earlier in the week that Hassan's decision to stay beyond his term endangered the people's right to elect a new leader and called for the election to be concluded soon.
The Maldives has seen much upheaval in the five years since its first multiparty election. There has been conflict between the judiciary, Parliament and the presidency, which often worked in different directions. The judiciary and bureaucracy were often accused of being loyal to Gayoom, the former autocratic ruler.
Nasheed was elected in 2008, but resigned midway through his term last year after weeks of public protests and declining support from the military and police over his decision to detain a senior judge whom he perceived to be biased. He later said he was ousted in a coup, but an inquiry commission rejected the allegation.
The Maldives is a predominantly Muslim nation of 350,000 people. About 240,000 Maldivians were eligible to vote Saturday, and turnout was more than 91 percent.