(CNN) -- Left-leaning Ollanta Humala won the Peruvian presidential runoff Monday, ending a hard-fought campaign during which he promised to spread the benefits of Peru's economic boom to the poor.
Though vote-counting continued, his opponent, Keiko Fujimori, conceded defeat, according to state news. Humala had previously claimed victory at a nighttime rally in downtown Lima on Sunday.
"The nation will only advance if the Peruvian family advances," he said to throngs of cheering supporters in the city's Dos de Mayo square.
He vowed to create a unity government and said he would focus on helping the country's most vulnerable.
Humala also addressed the need to improve the nation's infrastructure, water, sanitation and education, particularly in rural areas.
Those were promises he had made repeatedly throughout the campaign that set Humala, an ex-army officer, against Fujimori, a right-wing lawmaker and the daughter of a former president who is currently in prison on a 25-year sentence for human rights abuses.
With more than 90% of ballots counted Monday, Humala had 51.5% of the vote, versus Fujimori's 48.5%, according to the county's official electoral body.
His all-but-certain victory earlier in the day sent shocks through Peru's stock market.
It closed early Monday after its general index fell more than 12.5% -- its biggest one-day drop ever. Mining stocks, in particular, suffered.
"This activity in the market is directly linked to the electoral process. Trust (in the new government) seems to be the issue," said Daniel Romero, a financial analyst at Sociedad Agente de Bolsa in Lima.
"The selling is being led mostly by foreign investors," he added. "They're the most sensitive because they don't know what has been going on politically here in Peru."
Romero urged Humala to move quickly in naming a new finance minister after he takes office on July 28
For months, the candidacy of Humala, a past ally of Venezuelan President Hugo Chavez, has made some investors uneasy. They fear he could introduce higher taxes and redirect policies that have helped to push economic growth.
In a recent interview with CNN en Espanol, Humala denied his goal was a Chavez-style social revolution in Peru.
"When we speak about revolution, we're speaking about a revolution in education, which is something fundamental," Humala said. "We have to build our own future. We believe that the Venezuelan model doesn't apply in Peru."
Pollsters in Peru had said Sunday that Humala looked likely to win the presidency, and election officials said the partial results were somewhat skewed in favor of Lima and other urban areas.
Rural regions, where Humala was expected to perform best, were slower to report.
The runoff election was a face-off between two candidates with little in common.
Humala, 48, narrowly lost a 2006 election bid, in part because many saw him as a close ally of Venezuela's Chavez, intent on turning the country to the left.
That's a point his rival, 36-year-old Fujimori, hammered on throughout her campaign.
At a closing rally last week in Paseo Colon, a historic avenue in the capital Lima, Fujimori went on the offensive as she addressed a crowd of thousands.
"There are recordings and witnesses that prove that this gentleman is a good soldier of Chavez," she said to cheering crowds. "I am not going to allow other countries to interfere in the sovereignty of our country. I'm going to defend it!"
Humala, a former army officer linked to a 2000 military uprising, has tried to distance himself from such perceptions, swapping his trademark red T-shirts for suits.
Like her opponent, Fujimori was forced to answer uncomfortable questions about her past during this year's election. She is the daughter of former Peruvian President Alberto Fujimori, who is currently in prison on a 25-year sentence for human rights crimes.
Many Peruvians credit the elder Fujimori with defeating insurgencies that ravaged the South American nation for years and for enacting economic reforms that stabilized the Peruvian economy.
However, he is also criticized for corruption, having an authoritarian streak and the widespread rights abuses that were committed under his watch.
During the campaign, protesters accused his daughter of planning to grant the former president amnesty if she won, as she said she might do in a 2008 interview.
She later backed away from those remarks.
Centrist candidates, including former President Alejandro Toledo, former Lima Mayor Luis Castaneda and former Finance Minister Pedro Pablo Kuczynski, cannibalized each others' votes during the first round of voting in April.
In that round, Humala garnered more than 30% of the vote, while Fujimori ended slightly above 23%. Under Peruvian law, only the top two contenders advance to a second round.
After the elimination of the more centrist candidates in April, Peru's 2010 Nobel literary laureate Mario Vargas Llosa, a former presidential candidate himself, described the race as a choice between "terminal cancer and AIDS."
Andrea Stiglich, a member of the Economist Intelligence Unit team of Latin American analysts, said the election was a triumph of extremes.
"This election was meant to be the election of a centrist policy continuity candidate, and what we have is a first round that has yielded a result between two extremes in the left and the right," she said before the second-round vote.
Current Peruvian President Alan Garcia was not permitted to run for a consecutive term.
"I will get behind whoever wins," he said on Sunday before voting closed. "The task (of running the country) is not easy and they (will) need everyone's support."
The new president will face many of the same challenges Garcia did: Persistent poverty, protests around the rights to natural resources and violence from remnants of a leftist insurgency that helped to make Peru the world's largest producer of coca, the raw ingredient of cocaine.
On the eve of the election, five soldiers were killed in an attack in the country's southern province of Cusco, state news said. They were reportedly on their way to provide local police with additional security for the election when they were ambushed.
CNN's Dana Ford contributed to this report.