(Venezuelan election law prohibits any publication of results inside the country before an official announcement from the election board)
By Daniel Wallis and Todd Benson
CARACAS (Reuters) - Venezuela's presidential election looked headed for a close finish on Sunday with President Hugo Chavez facing an unprecedented challenge to his socialist rule from a young rival tapping into discontent over crime and cronyism.
An energetic campaign by centrist state governor Henrique Capriles, 40, has given the opposition its best chance in 14 years to unseat the popular president and take the reins of South America's leading oil exporter.
Chavez has used record oil revenue to support ideological allies around the world while taking a fiercely anti-American stance in global diplomacy, so the election is being watched eagerly from the United States and Cuba to Belarus and Iran.
With polling stations closing around 6 p.m. local time (2230 GMT), sources on both sides were predicting a narrow victory based on their monitoring of the vote, while local analysts said the ballot was looking too close to call.
Thousands of Chavez supporters lined the streets to welcome him as he arrived at the school in a Caracas hillside slum where he cast his vote. Some handed him flowers and one elderly woman serenaded the president with a folk song in his honor.
"Today is a day of joy, a day of democracy, a day for the fatherland," Chavez said, adding that a massive turnout meant voting could take longer than expected.
In a show of vigor, Chavez - who underwent grueling cancer treatment in the past year - shadow-boxed with U.S. actor Danny Glover, who was on hand with other celebrity fans of the Venezuelan leader to watch him vote.
In poor neighborhoods, where Chavez draws his most fervent following, supporters blew bugles and trumpets in a predawn wake-up call. In the run-down center of Caracas, red-clad loyalists shouted "Long live Chavez!" from the back of trucks.
Despite his remarkable comeback from cancer, Chavez, 58, could not match the energy of past campaigns - or the pace set by his 40-year-old basketball-loving opponent.
Capriles, a boyish looking lawyer-turned-politician who has never lost an election, has rallied support by focusing on the day-to-day problems that worry voters most, such as high crime, power blackouts and endemic corruption.
Sporting what he called his "lucky shoes," the superstitious Capriles struck a conciliatory tone after voting. "Whatever the people decide today is sacred," he said to applause from supporters. "To know how to win, you have to know how to lose."
In wealthy enclaves of the capital, his supporters geared up for the vote by banging pots and pans overnight.
"Today I'm doing my bit to build a new Venezuela," said Francesca Pipoli, 26, walking to vote with two friends in a rich Caracas district. "Capriles for president!" they sang.
In the United States, Venezuelan expats flocked to New Orleans to vote - mostly for Capriles - after Chavez closed the country's consulate in Miami earlier this year.
During the campaign, most well-known pollsters had put Chavez in front. But two put Capriles just ahead, and his numbers had been creeping up in others.
Voting appeared smooth with a high turnout some said could reach 75 percent, but there was some worry there could be violence if the result is contested. There are no formal international observers, though a delegation from the UNASUR group of South American nations is "accompanying" the vote.
Local groups were also monitoring the election and both sides say they trust the electronic, fingerprint voting system. The opposition deployed witnesses to all of the 13,810 polling centers, from tiny Amazon villages to tough Caracas slums.
In a politically polarized country where firearms are common and the murder rate is one of the world's highest, tensions have risen in recent weeks. Three Capriles activists were shot and killed by alleged Chavez loyalists on September 29.
After voting, Chavez pledged to respect the election results and called on the opposition to do the same. Some opposition activists fear Chavez could refuse to step down if he loses.
A Capriles victory would unseat the most vocal critic of the United States in Latin America, and could lead to new deals for oil companies in an OPEC nation that pumps about 3 million barrels a day and boasts the world's biggest crude reserves.
Capriles wants to copy Brazil's model of respect for private enterprise with strong social welfare programs if he is elected - but he would face big challenges from day one. For a start, he would not take office until January 2013, and some worry the Chavez camp might not cooperate with a Capriles transition team.
He would also have to develop a plan to tackle high inflation, price distortions and an overvalued currency, while surely butting heads with the National Assembly, judiciary and state oil company PDVSA - all dominated by "Chavistas."
Another big task would be to figure out the real level of state finances. Last month, a Reuters investigation found that half of public investment went into a secretive off-budget fund that is controlled by Chavez and has no oversight by Congress.
The president has denounced his foes as traitors and told voters they plan to cancel his signature social "missions," which range from subsidized food stores to programs that build houses and pay cash stipends to poor women with children.
The message resonates with his followers.
"If Chavez loses, it's all over. They're going to take away our missions and our hope," said Elida Perez, a 50-year-old housewife in Caracas.
If Chavez wins, he would likely consolidate state control over Venezuela's economy and continue backing leftist governments across Latin America, such as communist Cuba, which receives Venezuelan oil at a discount.
Any recurrence of Chavez's cancer would be a big blow to his plans, however, and could give the opposition another chance.
Investors who have made Venezuela's bonds some of the most widely traded emerging market debt are on tenterhooks.
"There is a perception that a tight electoral outcome may trigger social and political unrest and market volatility," Goldman Sachs said in a research note.
Results were due any time starting late on Sunday evening.
The electoral authority says it will only announce the results once there is an "irreversible trend" and parties are barred from declaring victory in advance of that announcement. (To follow us on Twitter: @ReutersVzla) (For multimedia coverage, go to reut.rs/QzUtvN) (Additional reporting by Andrew Cawthorne, Deisy Buitrago, Mario Naranjo, Liamar Ramos and Girish Gupta; Editing by Kieran Murray and Christopher Wilson)