LIMA, Peru — Leftist military man Ollanta Humala declared victory Sunday night after unofficial results showed him narrowly winning a bitterly contested presidential runoff against the daughter of disgraced former President Alberto Fujimori.

Humala had promised the poor a greater share of Peru's mineral wealth, and in a victory speech to a crowd of more than 10,000 said the nation's impressive economic growth would "be the great motor of the social inclusion Peruvians desire."

Humala won 51.5 percent of the vote against 48.5 percent for Keiko Fujimori with all ballots counted, according to the independent election watchdog Transparencia, whose track record in previous elections is solid.

First official results, with 78 percent of the vote counted, had the race much closer, with Humala ahead with 50.1 percent. But officials cautioned that the count was light on rural districts where Humala fared better.

Rife with mudslinging and dirty tricks, the election was marred by doubts about both candidates' commitment to democracy. Fujimori's father is serving a 25-year prison term for rights abuses and corruption and she shares the same inner circle of advisers. Humala has been accused of violent excesses as an army counterinsurgency unit commander in the 1990s.

Humala, 48, allied himself closely with socialist Venezuelan President Hugo Chavez in his first run for the office in 2006, which he narrowly lost to Alan Garcia. This time he softened his radical rhetoric and disavowed Chavez, promising instead to follow Brazil's market-friendly model.

He failed to win over the business elite, however, which fears Humala will nationalize industries and expropriate private property. His rise in popularity was mirrored by Lima stock market selloffs.

Humala said in remarks he read at a Lima hotel in declaring victory that he intends to "build a government of national reconciliation, representative of the collective democratic forces and open to civil society."

His champions were the neglected — one in three Peruvians are poor and have gained little or nothing from a mining bonanza that turned its economy into Latin America's top performer the past decade.

Jose Romero, a 58-year-old construction worker who said he was harassed for labor organizing during Alberto Fujimori's regime, was overjoyed by Humala's win.

"We're geting everything back with him. Good jobs will come back. There won't be corruption. I believe in his word," said Romero, who is from Peru's poorest state, Huancavelica.

Keiko Fujimori appeared briefly before supporters five hours after polls closed, asking her supporters to "wait responsibly and with prudence" the official results.

Exit polls gave Humala better than 70 percent of the vote in four poor highland states including Puno, where Aymara Indians who object to a planned Canadian-owned silver mine suspended a nearly month-long highway blockade so people could vote. The protesters fear the mine will poison their water.

Fujimori, meanwhile, captured Lima but by a modest margin.

Humala finished first in the election's April 10 first round, when three centrist candidates together split 45 percent of the vote. He got a boost with the endorsement of fourth-place finisher Alejandro Toledo, Peru's president in 2001-06. Earlier, Toledo had likened voting for Humala to "a jump into the abyss."

Had Toledo and the other two eliminated centrists united behind a single candidate they could have elbowed out Keiko Fujimori. But Peru is a country where personality decides elections rather than political party affiliations or ideologies. Its parties are weak, its political class considered extremely corrupt.

That opens the door for outsiders like Humala and Fujimori's father, Alberto.

He vanquished hyperinflation and fanatical Shining Path rebels during his autocratic 1990-2000 presidency. A fifth of Peruvians revere the man, but his legacy of corruption hurt his daughter, a 36-year-old congresswoman. Humala harped on it. He vowed to throw corrupt politicians in jail and make it easier for citizens to recall their elected leaders.

Peru's best-known public intellectual, 2010 Nobel literature laureate Mario Vargas Llosa, said Humala's win "saved democracy."

"What's important is that we have been freed from the return to power of a dictatorship that was terribly corrupt and bloody," he told CPN radio. "We should congratulate ourselves and celebrate."

Both candidates promised a raft of giveaways for the poor, including free school meals and preschool care. Humala promised a government pension for all at age 65.

But, unlike his opponent, Humala also insisted on taxing windfall mining profits and exporting less natural gas so it is cheaper for Peruvians.

Humala backed down during the runoff campaign from early calls for renegotiating free trade agreements and rewriting Peru's constitution to "create an economic regime with social justice as its objective." Two weeks ago, he swore on the Bible to respect democracy and press freedom.

"I will be a president who acts only within the constitution and the rule of law," he said.

Humala insisted he'd steer Peru closer to the United States and Brazil than to Chavez's leftist camp, which includes Venezuela, Bolivia and Ecuador, none of which currently have U.S. ambassadors.

Former New Mexico Gov. Bill Richardson, in Peru as an Organization of American States election observer, met with both candidates and said he didn't consider Humala another Chavez.

"He is a nationalist and an enigma with evolving views and a pragmatic streak," Richardson said. "I think he's educable and the business community should give him a chance."

Skeptics fear Humala will put Peru on a course similar to the 1968-75 leftist military dictatorship of Gen. Juan Velasco, for whom Humala expressed esteem during the 2006 race.

At stake, for starters, is the potential for losing more than $40 billion in investment pledged over the next decade to develop Peru's mines of gold, silver, copper and other metals.

"He's going to change the constitution and stay in power. And the investors are going to go away, too," said Luis Rodriguez, a Villa El Salvador street vendor who voted for Keiko Fujimori.

Associated Press writers Carla Salazar and Franklin Briceno contributed to this report.

Frank Bajak on Twitter: