With 91 per cent of the vote counted, Ortega had 38 per cent of the vote compared to 29 per cent for Eduardo Montealegre, who was backed by the US.
Under Nicaraguan law, the winner must reach 35 per cent and have a five percentage point lead to win the election outright and avoid a runoff.
Ortega's supporters celebrated in the streets following the announcement, setting off fireworks.
Montealegre immediately conceded defeat, but said he and his party would spend the next five years ensuring that Ortega stayed true to his promises to support free trade and promote private business.
"We promise to continue our fight," he said.
The former president spent most of the 1980s fighting a US-backed Contra insurgency.
He lost the presidency in the 1990 election, ending Sandinista rule and years of civil war, and has spent the past 16 years attempting to be re-elected.
The former US president, Jimmy Carter, who served as an election observer, said on Tuesday in Managua that the US secretary of state, Condoleezza Rice, "assured me that no matter who was elected, the US will respond positively and favourably".
With the Cold War icon's victory, Nicaragua joined the list of Latin American nations with leftists at the helm.
Hugo Chavez, the Venezuelan president, had tried to help Ortega during the election campaign by shipping discounted oil to the poor, energy-starved nation.
"Latin America is ceasing to be - and forever - a backyard of US imperialism. Yankee, go home!" Chavez said on Tuesday in Venezuela.
The White House said warily late on Tuesday that it would work with Nicaragua president-elect Daniel Ortega, a former Marxist, based on his commitment to his country's "democratic future".
"The United States is committed to the Nicaraguan people. We will work with their leaders based on their commitment to and actions in support of Nicaragua's democratic future," said national security spokesman Gordon Johndroe.
Johndroe went on to emphasise that "the groundwork has been laid to allow for increased prosperity and opportunity for the Nicaraguan people" through channels like the US-Central American Free Trade Agreement (Cafta), US programmes to reward democratic and free market reforms, and debt relief.