The decision came after a day of fast-moving developments, including an offer from Morales to hold a new election. The crisis deepened dramatically when the country's military chief went on national television to call on him to step down.
"I am sending my resignation letter to the Legislative Assembly of Bolivia," the 60-year-old socialist leader said, portraying his departure as the culmination of a "coup d'etat."
He added: "I ask you to stop attacking the brothers and sisters, stop burning and attacking."
Before Morales had even finished his statement, people began honking their car horns in La Paz and other cities and took to the streets to celebrate, waving Bolivian flags and setting off fireworks.
"This is not Cuba, nor Venezuela. This is Bolivia, and Bolivia is respected," a crowd in the capital shouted.
Large crowds formed in the main squares in the capital, with many people rejoicing and some crying tears of joy. Protesters lay down in front of the presidential palace and set a coffin on fire to symbolize the death of the Morales government.
"We are celebrating that Bolivia is free," said one demonstrator near the presidential palace.
It was not immediately clear who would succeed Morales. His vice president also resigned as did the Senate president, who was next in line. The only other official listed by the constitution as a successor, the head of the lower house, already had resigned.
Morales was the first member of Bolivia's indigenous population to become president and was in power for 13 years and nine months, the longest span in the country's history.
But his claim to have won a fourth term last month set off unrest that left three people dead and over 100 injured in clashes between his supporters and opponents.
Earlier Sunday, the Organization of American States said in a preliminary report that it had found a "heap of observed irregularities" in the Oct. 20 election and that a new vote should be held.
Morales agreed to that. But within hours, the military chief, Gen. Williams Kaliman, made it clear that would not be sufficient.
"After analyzing the situation of internal conflict, we ask the president to resign, allowing peace to be restored and stability to be maintained for the good of our Bolivia," Kaliman said.
The leadership crisis escalated in the hours leading up Morales' resignation. Two government ministers in charge of mines and hydrocarbons, the Chamber of Deputies president and three other pro-government legislators announced their resignations. Some said opposition supporters had threatened their families.
In addition, the head of Bolivia's Supreme Electoral Tribunal, Maria Eugenia Choque, stepped down after the release of the OAS findings. The attorney general's office said it would investigate the tribunal's judges for possible fraud, and police later said Choque had been detained along with 37 other officials on suspicion of electoral crimes.
Mexico's government reported Sunday night that 20 members of Bolivia's executive and legislative branches were at the official Mexican residence in the capital seeking asylum.
Mexican Foreign Secretary Marcelo Ebrard also said on Twitter that Mexico would offer asylum to Morales if should ask for it. There was no indication that Morales had done that.
Earlier, Ebrard criticized the involvement of the Bolivian military in the day's events crisis, saying that "we reject it."
In a tweet, Ebrard said: "Mexico will maintain its position of respect for democracy and institutions. Coup no."
Jennifer Cyr, an associate professor of political science and Latin American studies at the University of Arizona, also voiced concern about the military commander calling on Morales to resign, calling it "extremely troubling" and "sad."
The OAS report and Morales' acceptance of a new election were positive steps that could have calmed Bolivia's divisions, she said. "Now I am not sure what will happen."
Morales was first elected in 2006 and went on to preside over a commodities-fed economic boom in South America's poorest country. The combative former leader of a coca growers union, he paved roads, sent Bolivia's first satellite into space and curbed inflation.
But many who were once excited by his fairy-tale rise grew wary of his reluctance to leave power.
He ran for a fourth term after refusing to abide by the results of a referendum that upheld term limits for the president. He was able to run because Bolivia's constitutional court disallowed such limits.
After the Oct. 20 vote, Morales declared himself the outright winner even before official results indicated he obtained just enough support to avoid a runoff with opposition leader and former President Carlos Mesa. A 24-hour lapse in releasing results fueled suspicions of vote-rigging.
The OAS sent a team to look into the election. It called for a new contest with a new electoral tribunal.
"Mindful of the heap of observed irregularities, it's not possible to guarantee the integrity of the numbers and give certainty of the results," the OAS said in a statement.
The U.S. State Department issued a statement calling for the OAS to send a mission to Bolivia to oversee the electoral process. "The Bolivian people deserve free and fair elections," it said.
During the unrest, protesters torched the headquarters of local electoral tribunal offices and set up roadblocks that paralyzed parts of Bolivia.
The pressure on Morales had increased ominously Saturday when police on guard outside the presidential palace abandoned their posts, and police officers retreated to their barracks in at least three cities.
The state news agency ABI said Morales announced his resignation from Chapare province, where he began his career as a union leader. At the end of his speech, he said he was returning to Chapare.
"I return to my people who never left me. The fight goes on," he said.