The unanimous decision by the Federal Electoral Tribunal rejected allegations of systematic fraud and awarded Calderon the presidency by 233,831 votes out of 41.6 million cast in the July 2 elections — a margin of 0.56 percent. The ruling cannot be appealed.
Calderon now must win over millions of Mexicans angry that President Vicente Fox, who is from Calderon's party, didn't make good on promises of sweeping change — and fend off thousands of radicalized leftists who say they will stop at nothing to undermine his presidency.
Lopez Obrador, whose support is dwindling but becoming more radical, said he will not recognize the new government.
"I do not recognize someone who tries to act as the chief federal executive without having legitimate and democratic representation," Lopez Obrador told followers at Mexico's main central plaza, the Zocalo.
Lopez Obrador has vowed to block Calderon from taking power Dec. 1. Protesters outside the tribunal wept as the decision was announced and set off firecrackers that shook the building.
"We aren't going to let him govern!" Thomas Jimenez, a 30-year-old law student, screamed as hundreds of protesters threw eggs and trash at the courthouse.
The decision by the seven judges — who have split their votes in disputes about other elections — also found that Fox endangered the election by making statements that favored Calderon, and that business leaders broke the law by paying for ads against Lopez Obrador, who promised to govern on behalf of the poor.
But the problems weren't serious enough to annul the results, they said.
"There are no perfect elections," Judge Alfonsina Berta Navarro Hidalgo said.
The court rejected most of Lopez Obrador's allegations, including his claim that an ad campaign comparing him to Venezuelan President Hugo Chavez unfairly swayed voters. The court also dismissed Lopez Obrador's claim of subliminal messages in television ads by pro-Calderon businesses.
The court's president, Leonel Castillo, called on Mexicans to unite and mend the deep divisions the election revealed.
"I hope we conclude this electoral process leaving confrontation behind," he said.
A smiling Calderon emerged from party offices to wave at supporters. He was scheduled to address the nation later Tuesday and meet with Fox on Wednesday.
Calderon, a 44-year-old former energy secretary and career politician, promised during the campaign to create jobs and keep the economy growing, and since the election he has adopted some of Lopez Obrador's ideas on how to help Mexico's poor majority.
Fox greeted the court's decision with a smile during an appearance in Cancun, then publicly congratulated Calderon and invited Lopez Obrador to begin talks aimed at "strengthening the nation and our democracy."
Markets, which had expected Tuesday's ruling, were unchanged. World leaders, including Japan's prime minister and several Central American presidents, congratulated Calderon on his victory.
The White House, in a statement, congratulated the people of Mexico on the certification of a "free and fair electoral process."
"We congratulate Felipe Calderon on his victory and look forward to working with him and his team," the statement said, adding that the United States expects its relationship with Mexico to continue to be productive for both countries.
Tuesday's ruling came two months, three days, and tens of thousands of pages of legal challenges after voters cast their ballots. In comparison, the U.S. presidential election of 2000 remained in dispute for only 35 days.
The decision was unlikely to end the demonstrations that have crippled Mexico City's center or to heal the nation's growing political divide.
In the Zocalo plaza, thousands in a month-old protest camp chanted: "If there is no solution, there will be revolution!"
"Taking up arms is the only way," said Angel Sinsun, 80. "They'll never give us power with peaceful resistance or with negotiations."
Lopez Obrador has called on his followers to remain peaceful. His movement has become increasingly radicalized since the election, and polls indicate he lost support after lawmakers from his party blocked Fox's last state-of-the-nation address on Friday.
On Tuesday, the Convergencia party — one of three that nominated Lopez Obrador for the presidency — left the electoral alliance, saying "it is time to rethink strategies."
Lopez Obrador adviser Manuel Camacho told The Associated Press that the court's recommendation "does not take into account what is actually happening in the country."
"The court is going to be questioned seriously about its decision," he said, adding: "We have the responsibility to conduct ourselves peacefully."
No violence was reported, but police surrounded the headquarters of Calderon's National Action Party, where businesswoman Susanna Rivera was among a few drivers honking in support of the conservative former energy secretary.
"It's marvelous. It's perfect," she said of the court's decision. "We are happy because he is a decent, educated person." She said Lopez Obrador's supporters would never accept Calderon because "they are a bunch of crazies."
Neither candidate attended the court session. Lopez Obrador ate breakfast with lawmakers, then went to his protest tent in the Zocalo plaza, where he has been sleeping for nearly two months.
Supporters greeted him with calls of "You are not alone!"