CARACAS, Venezuela — Voters across this country turned out in large numbers on Sunday, standing in lines that snaked around city blocks to cast ballots in a landmark presidential election that could give the fiery socialist Hugo Chávez a new term or replace him with a youthful, more moderate challenger, Henrique Capriles Radonski.


Voting, and then the counting, appeared likely to continue well into the night. Though the balloting mostly went smoothly around the country, there were a few reports of hitches — mainly technical problems with electronic voting machines — that caused long delays at some locations, and polling places were instructed to keep working until everyone on line at closing time had the chance to vote. Results were not expected until after the voting was complete at every polling station.


The day began as early as 3 a.m. in poor neighborhoods where Mr. Chávez enjoys strong support, as activists drove around on motorcycles and trucks, blowing bugles and air horns and blaring his campaign music to rouse people to go out to vote. In some neighborhoods, residents turned out before the polls opened at 6 a.m. By early morning, the lines at some locations in the capital were around the block.


“I’ve been voting here my whole life and it’s the first time I’ve seen such a long line,” said Elsi Fernandes, 33, who waited with her 6-year-old daughter for more than two hours before casting her vote for Mr. Capriles at a school in Catia, a poor area of central Caracas. Television reports showed long lines in other parts of the country as well.


“There’s enthusiasm, but it’s also very quiet,” Ms. Fernandes, a teacher, said of those waiting outside. “That’s not very much like us Venezuelans.”


Ms. Fernandes said she sensed a nervous expectation among voters in line. Soldiers in green fatigues were stationed at the polling places, as is customary in Venezuelan elections.


Mr. Chávez has won each of his previous elections by margins of 22 percent or more, but expectations rose on Sunday that the outcome this time would be much closer.


During the campaign, Mr. Chávez vowed that he would give the opposition an epic beating. But speaking to reporters after he cast his vote in Caracas, the president dismissed any suggestion that he would refuse to acknowledge an opposition victory if the vote count ran against him.


“You should not have any doubt that we will recognize the results, whatever they are,” Mr. Chávez told reporters at his polling place. “Whether it is a one-vote difference or three million votes, responsible political participants have to recognize the results.”


Venezuela is a major oil supplier to the United States and was a longtime American ally, but during his tenure Mr. Chávez has steered his country away from Washington. He is close to countries like Cuba and Iran, and has been a thorn in the side of the United States in Latin America, leading a bloc critical of American policies.


At home, Mr. Chávez has championed social programs that provide education, housing and subsidized food to the poor, and he has sought to create a socialist economy, nationalizing many businesses. He has governed with autocratic reach, undercutting the independence of the country’s legislature and courts.


The president started the race with a large lead in opinion polls. But Mr. Capriles ran a strong campaign, making inroads in poor areas that were fiercely loyal to Mr. Chávez, and in recent weeks his support appeared to surge.


Mr. Capriles jabbed away at widespread corruption, government mismanagement and out-of-control violent crime. He called for Venezuelans to work together, a contrast to Mr. Chávez, who delights in demeaning and insulting his opponents.


And Mr. Capriles promised to keep and improve Mr. Chávez’s signature social programs. Mr. Capriles has crisscrossed the country, keeping up a manic pace for months. Mr. Chávez, who has been battling cancer, sometimes went two or three days without a campaign appearance.


In Cumaná, a city in the northeast, broken voting machines delayed voting for hours at a polling place at the National Open University. Finally, at around 1 p.m., the authorities began allowing voters to use paper ballots instead.


“I’d rather wait six hours in line than endure six years more of this Chávez government,” said Antonio de la Rosa, 63, who had been at the polling station since 6:30 a.m.


In the Catia neighborhood of the capital, María Elena Severine, 59, a cleaning woman for a bank, said that Mr. Chávez was still as fresh a candidate as when he first ran in 1998. “I like my president,” she said. “He is the revolution. He is change.”