But Capriles' promises to seriously address violent crime that has spun out of control, streamline a patronage-bloated bureaucracy and end rampant corruption proved inadequate against Chávez's charisma, well-oiled political machine and a legacy of putting Venezuela's poor first with generous social welfare programs.
Chávez will now have a freer hand to push for an even bigger state role in the economy and continue populist programs. He's also likely to further limit dissent and deepen friendships with U.S. rivals.
A Capriles victory would have brought a radical foreign policy shift including a halt to preferential oil deals with allies such as Cuba, along with a loosening of state economic controls and an increase in private investment.
It was Chávez's third re-election in nearly 14 years in office. It was also his smallest victory margin. In 2006, he won by 27 percentage points.
"I can't describe the relief and happiness I feel right now," said Edgar Gonzalez, a 38-year-old construction worker.
He ran through crowds of Chávez supporters packing the streets around the presidential palace wearing a Venezuelan flag as a cape and yelling: "Oh, no! Chávez won't go!"
"The revolution will continue, thanks to God and the people of this great country," said Gonzalez.
Voter turnout was an impressive 81 percent, compared to 74 percent in 2006. Chávez paid close attention to his military-like get-out-the-vote organization at the grass roots, stressing its importance at campaign rallies. The opposition said he unfairly plowed millions in state funds into the effort.
Chávez spent heavily in the months before the vote, building public housing and bankrolling expanded social programs.
"I think he just cranked up the patronage machine and unleashed a spending orgy," said Michael Shifter, president of the Washington-based Inter-American Dialogue think tank.
But Shifter also didn't deny the affinity and gratefulness Venezuela's poor feel for Chávez. "Despite his illness, I still think he retains a large emotional connection with a lot of Venezuelans that I think were not prepared to vote against him."
Chávez spoke little during the campaign about his fight with cancer, which since June 2011 has included surgery to remove tumors from his pelvic region as well as chemotherapy and radiation treatment. He has said his most recent tests showed no sign of illness.
In conceding defeat, Capriles told supporters not to feel defeated.
"We have planted many seeds across Venezuela and I know that these seeds are going to produce many trees," told a hall of supporters.
Despite winning a February primary that unified the opposition, Capriles proved no match for Chávez's electoral prowess.
David Valencia, a 20-year-old Capriles supporter, said he was disappointed but that he hadn't lost hope despite the loss.
"There is still a sense in our hearts of wanting a better country," he said.
One pro-Chávez voter, private bodyguard Carlos Julio Silva, said that whatever his faults, Chávez deserved to win for spreading the nation's oil wealth to the poor with free medical care, public housing and other government largess. The country has the world's largest proven oil reserves.
"There is corruption, there's plenty of bureaucracy, but the people have never had a leader who cared about this country," Silva said after voting for Chávez at a school in the Caracas slum of Petare.
At many polling places, voters began lining up hours before polls opened at dawn, some snaking for blocks in the baking Caribbean sun. Some shaded themselves with umbrellas. Vendors grilled meat and some people drank beer.
Chávez's critics say the president has inflamed divisions by labeling his opponents "fascists," ''Yankees" and "neo-Nazis," and it's likely hard for many of his opponents to stomach another six years of the loquacious and conflictive leader.
Some said before the vote that they'd consider leaving the country if Chávez won.
Gino Caso, an auto mechanic, said Chávez is power-hungry and out of touch with problems such as crime. He said his son had been robbed, as had neighboring shops.
"I don't know what planet he lives on," Caso said, gesturing with hands blackened with grease. "He wants to be like Fidel Castro end up with everything, take control of the country."