* Chavez defeats youthful opposition rival Capriles
* Win extends Chavez's rule to 20 years, health permitting
* Chavez's supporters celebrate in the streets
By Andrew Cawthorne and Eyanir Chinea
CARACAS, Oct 7 (Reuters) - Venezuela's socialist President Hugo Chavez comfortably won re-election on Sunday, quashing the opposition's best chance at unseating him in 14 years and cementing himself as a dominant figure in modern Latin American history.
A fist-pumping Chavez led throngs of supporters in celebration from the balcony of the presidential palace - just months after cancer treatment had taken him out of the public eye and left him fending off rumors he was dying.
A new six-year term will extend his rule of the OPEC member state to two decades, giving him a chance to deepen his oil-revenue-fueled socialism while continuing to support left-wing allies in Latin America, though a possible recurrence of cancer still hangs over him.
"Today we've shown that Venezuela's democracy is one of the best democracies in the world, and we will continue to show it," the 58-year-old Chavez shouted, dressed in a signature red shirt and waving a replica sword of independence hero Simon Bolivar.
Crowds roared, and the smoke of fireworks clouded the air.
Chavez took 54.42 percent of the vote, with 90 percent of the ballots counted, compared with 44.97 percent for young opposition candidate Henrique Capriles.
Since taking power in 1999, the flamboyant former soldier has become a global flag bearer of "anti-imperialism," gleefully baiting the U.S. government while befriending leaders from Iran to Belarus whom the West views with suspicion.
At home, casting himself as an heir to independence hero Simon Bolivar, Chavez has poured billions of dollars in oil revenues into anti-poverty programs, and skillfully used his humble roots and folksy oratory to build a close connection with the masses.
"Chavez is my joy. He will continue protecting the poor and defenseless," said Gladys Montijo, 54, a teacher.
Highlighting relief among Latin American allies, Argentine President Cristina Fernandez wrote via Twitter: "Your victory is our victory! And the victory of South America and the Caribbean!"
Opposition leaders appeared crushed by the loss, with some Capriles supporters bursting into tears at his campaign headquarters as the news sank in.
The youthful state governor put on a brave face, celebrating his "house-by-house" campaign as the start of a long road to changing the direction of the country.
"I hope a political movement that has been in power for 14 years understands that almost half the country does not agree with it," a subdued and tired-looking Capriles told crestfallen supporters.
Chavez's victory was considerably slimmer than his win of 25 percentage points in 2006, reflecting anger at his failure to fix basic problems such as crime, blackouts and corruption.
Record turnout of 80 percent on Sunday will boost Chavez's democratic credentials, though critics said his use of state resources made a mockery of fairness during the campaign.
After heavy campaign spending, South America's biggest oil exporter faces growing pressure to devalue its currency in 2013, likely spurring inflation that has been a top complaint of Chavez sympathizers.
In the past, Chavez has taken advantage of election wins to press forward with radical reforms. His often-capricious nationalizations may now turn to some untouched corners of Venezuela's banking, food and health industries.
Cancer, though, could change that.
The constitution says if an incumbent steps down in the first four years of a six-year term, a new vote would be called. Under such a scenario, Capriles or another opposition candidate would have another crack at power.
During a year's treatment starting in mid-2011, Chavez endured three operations for two cancerous tumors, and chemotherapy that left him bald, exhausted and fearing death at his lowest point.
He wrongly declared himself cured once, and repeated that in July after a recurrence, prompting skepticism from doctors who say that at least two years must pass before a cancer patient can be given a clean bill of health.
Chavez has looked bloated and at times exhausted in recent months, but he ran a surprisingly energetic end to his campaign, even managing to dance, sing and strum a guitar at rallies.
Any sign of a downturn in his health in the future would stoke a succession debate in the ruling Socialist Party.
Congress head Diosdado Cabello, Foreign Minister Nicolas Maduro and Vice President Elias Jaua all look well-placed for a potential push for leadership.
But none of Chavez's allies come anywhere near his popularity, so if there were to be another election, Capriles could be a favorite after a widely praised campaign that has made him well-known across the nation of 29 million people.
Though the 40-year-old Capriles is the once-rudderless opposition's best leader of the Chavez era, his position is not guaranteed. There are other young political figures - including Zulia state governor Pablo Perez and telegenic former Caracas district mayor Leopoldo Lopez - waiting in the wings.
Now, Capriles and other leaders of the Democratic Unity coalition must dust themselves off and prepare for state governorship elections in December, when they will hope at least to increase the opposition's influence at the local level.
Chavez's new six-year term begins on Jan. 10.
His latest election win continues a remarkable story that began with his birth on July 28, 1954 in a mud hut belonging to his grandmother in the rural village of Sabaneta.
He joined the army and spent years plotting before a failed coup in 1992 against President Carlos Andres Perez.
On his way into jail, wearing a red military beret that was to become his trademark, Chavez gave a two-minute televised speech admitting that his revolution had failed "for now." The speech electrified the nation and launched his political career.
Pardoned in 1994, Chavez began crisscrossing the country sharing his vision and eventually shocking the political elite by sweeping to victory at the ballot box in 1998.
With private media and business leaders opposed to his rule, Chavez was briefly toppled by army dissidents and street protests in 2002 - but returned two days later thanks to military loyalists and popular counter-demonstrations.
He also survived an economically crippling oil strike.
Chavez's win will probably mean more foreign investment from politically allied countries such as China, Russia, Iran and Belarus, while Western investors are more cautious. Relations with Washington are also likely to remain on edge, though Venezuelan oil has continued to flow to the United States over the years despite the diplomatic tension.
Wall Street had been hoping for a Capriles win, so prices of Venezuelan bonds - among the most actively-traded emerging market debt - are likely to dip on Chavez's triumph.