Updated

Hugo Chávez's legacy continue — barely.

The late leftist Venezuelan president's hand-picked successor, Nicolas Maduro, won the country's presidential election Sunday by a stunningly narrow margin over opposition challenger, Henrique Capriles, who immediately demanded an official recount.

From crime to power blackouts, Venezuelans must now prepare for potentially more headaches for a country shaken by the death of its dominating leader.

One key Chavista leader made known his dismay over the outcome of Sunday's election that was supposed to cement the self-styled "Bolivarian Revolution" of their beloved president as Venezuela's destiny. National Assembly President Diosdado Cabello, who many consider Maduro's main rival within their movement, tweeted: "The results oblige us to make a profound self-criticism."

Maduro's victory followed an often ugly, mudslinging campaign in which the winner promised to carry on Chávez's legacy, while challenger Henrique Capriles' main message was that Chávez put his country -- home to one of the largest oil reserves in the world -- on the road to ruin.

"This is a result in which the 'official winner' appears as the biggest loser. The 'official loser' —the opposition — emerges even stronger than it did six months ago."

— Javier Corrales, Amherst College political scientist

More On This...

Despite the ill feelings, both men sent their supporters home and urged them to refrain from violence.

Maduro, acting president since Chávez's March 5 death, held a double-digit advantage in opinion polls just two weeks ago, but electoral officials said he got just 50.7 percent of the votes compared to 49.1 percent for Capriles, with nearly all ballots counted.

The margin was about 234,935 votes. Turnout was 78 percent, down from just over 80 percent in the October election that Chávez won by a nearly 11-point margin over Capriles.

Chavistas set off fireworks and raced through downtown Caracas blasting horns in jubilation. In a victory speech, Maduro told a crowd outside the presidential palace that his victory was further proof that Chávez "continues to be invincible."

But analysts called the slim margin a disaster for Maduro, a former union leader and bus driver in the radical wing of Chavismo, who is believed to have close ties to Cuba.

At Capriles' campaign headquarters, people hung their heads quietly as the results were announced by an electoral council stacked with Chávez loyalists. Many started crying; others just stared at TV screens in disbelief.

Later, Capriles emerged to angrily reject the official totals: "It is the government that has been defeated."

He said his campaign came up with "a result that is different from the results announced today."

"The biggest loser today is you," Capriles said, directly addressing Maduro through the camera. "The people don't love you."

Venezuela's electronic voting system is completely digital, but also generates a paper receipt for each vote, making a vote-by-vote recount possible.

Armed forces joint chief, Gen. Wilmer Barrientos, called on the military to accept the results.

A Capriles' campaign staffer told The Associated Press on condition of anonymity that the candidate met with the military high command after polls closed. But campaign official Armando Briquet later denied that a meeting was held.

Capriles, an athletic 40-year-old state governor, had mocked and belittled Maduro as a poor, bland imitation of Chávez.

Maduro said during his victory speech that Capriles had called him before the results were announced to suggest a "pact" and that Maduro refused. Capriles' camp did not comment on Maduro's claim, though Capriles began his speech by declaring he doesn't "make pacts with lies or corruption."

Maduro, a longtime foreign minister to Chávez, rode a wave of sympathy for the charismatic leader to victory, pinning his hopes on the immense loyalty for his boss among millions of poor beneficiaries of government largesse and the powerful state apparatus that Chávez skillfully consolidated.

Capriles' main campaign weapon was to simply emphasize "the incompetence of the state."

Millions of Venezuelans were lifted out of poverty under Chávez, but many also believe his government not only squandered, but plundered, much of the $1 trillion in oil revenues during his 14-year rule.

Venezuelans are afflicted by chronic power outages, crumbling infrastructure, unfinished public works projects, double-digit inflation, food and medicine shortages, and rampant crime — one of the world's highest homicide and kidnapping rates — that the opposition said worsened after Chávez disappeared to Cuba in December for what would be his final surgery.

Analyst David Smilde at the Washington Office on Latin America think tank predicted the victory would prove pyrrhic and make Maduro extremely vulnerable.

"It will make people in his coalition think that perhaps he is not the one to lead the revolution forward," Smilde said.

Other analysts concurred with that perspective.

"This is a result in which the 'official winner' appears as the biggest loser," said Amherst College political scientist Javier Corrales. "The 'official loser' —the opposition — emerges even stronger than it did six months ago. These are very delicate situations in any political system, especially when there is so much mistrust of institutions."

Many across the nation put little stock in Maduro's claims that sabotage by the far right was to blame for worsening power outages and food shortages in the weeks before the vote.

"We can't continue to believe in messiahs," said Jose Romero, a 48-year-old industrial engineer who voted for Capriles in the central city of Valencia. "This country has learned a lot and today we know that one person can't fix everything."

In a Chavista stronghold in Petare outside Caracas, Maria Velasquez, 48, who works in a government soup kitchen that feeds 200 people, said she voted for Chávez's man "because that is what my comandante ordered."

Reynaldo Ramos, a 60-year-old construction worker, said he "voted for Chávez" before correcting himself and saying he chose Maduro.

"We must always vote for Chávez because he always does what's best for the people and we're going to continue on this path," Ramos said.

The governing United Socialist Party of Venezuela deployed a well-worn, get-out-the-vote machine spearheaded by loyal state employees. It also enjoyed the backing of state media as part of its near-monopoly on institutional power.

Capriles' camp said Chavista loyalists in the judiciary put them at glaring disadvantage by slapping the campaign and broadcast media with fines and prosecutions that they called unwarranted. Only one opposition TV station remains and it's being sold to a new owner Monday.

At rallies, Capriles would read out a list of unfinished road, bridge and rail projects. Then he asked people what goods were scarce on store shelves.

Capriles showed Maduro none of the respect he earlier accorded Chávez.

Maduro hit back hard, at one point calling Capriles' backers "heirs of Hitler." It was an odd accusation considering that Capriles is the grandson of Holocaust survivors from Poland.

Maduro focused his campaign message on his mentor: "I am Chávez. We are all Chávez."

He will face no end of hard choices for which Corrales, the Amherst analyst, said he has shown no skills for tackling.

Maduro has "a penchant for blaming everything on his 'adversaries' — capitalism, imperialism, the bourgeoisie, the oligarchs — so it is hard to figure how exactly he would address any policy challenge other than taking a tough line against his adversaries."

Venezuela's $30 billion fiscal deficit is equal to about 10 percent of the country's gross domestic product.

Many factories operate at half capacity because strict currency controls make it hard for them to pay for imported parts and materials. Business leaders say some companies verge on bankruptcy because they cannot extend lines of credit with foreign suppliers.

Chávez imposed currency controls a decade ago trying to stem capital flight as his government expropriated large land parcels and dozens of businesses.

Now, dollars sell on the black market at three times the official exchange rate and Maduro has had to devalue Venezuela's currency, the bolivar, twice this year.

Based on reporting by The Associated Press.

Follow us on twitter.com/foxnewslatino
Like us at facebook.com/foxnewslatino