Nicaragua's former leader, Daniel Ortega, has won the country's presidential election.
This is Mr Ortega's fourth attempt at the presidency
The one-time revolutionary has 38%, nine points ahead of his conservative rival Eduardo Montealegre, with more than 91% of votes counted.
Mr Montealegre conceded to his rival, but said he would hold him to account for his promises to promote business and free trade.
The US pledged to work with Nicaragua's leaders, if they back democracy.
"The United States is committed to the Nicaraguan people," said White House National Security Council spokesman Gordon Johndroe.
"We will work with their leaders based on their commitment to and actions in support of Nicaragua's democratic future."
Washington had previously warned that Mr Ortega's election could lose Nicaragua US aid.
Regional leaders were quick to congratulate Mr Ortega, including a leftist ally from his earlier period in power, Cuban President Fidel Castro.
In a statement read on Cuban TV, he hailed a "Sandinista victory that fills our people with happiness".
And Venezuelan President Hugo Chavez, a firm opponent of US policy in Latin America, enthused: "Latin America is leaving forever its role as the backyard of the North American empire. Yankee go home!"
There has been no reaction yet from Mr Ortega, who needed to win 40% of votes, or 35% and a five-point margin, to win outright and avoid a second round.
He will take office in January next year.
Mr Ortega led Nicaragua from 1979 to 1990, but says he has changed from the leader who seized property from the wealthy during the 1979 Sandinista revolution.
That assessment was endorsed by former US President Jimmy Carter, who was an observer in the elections.
However, the new president's opponents have expressed concern that he will take the nation back to the days of the civil war with the Contra rebels.
Turnout was reported to be high with some people having to join long queues to vote, but election observers reported no major problems.
Mr Ortega has unsuccessfully stood for president on three occasions following his sole success in 1984.
But the country's right wing, which previously always managed to field a single candidate against him, was divided on this occasion.
Mr Ortega has seen 16 years of conservative governments and says he wants an end to "savage capitalism".
But he says his revolutionary days are behind him - and his main priority is to secure foreign investment to help to ease widespread poverty.
He was also hoping for support from the 80% of Nicaraguans who live on $2 a day or less.
As a Marxist revolutionary in the 1980s, Mr Ortega led the country through a decade of civil war in which his Sandinista forces fought rebels known as the Contras, who were financed by the United States. About 50,000 people died in the conflict.
The incumbent, President Enrique Bolanos, has served the single five-year term allowed by the constitution.