BAMAKO, MALI -- Mali's president announced his resignation late Tuesday, just hours after armed soldiers seized him from his home in a dramatic power grab following months of protests demanding his ouster.

The news of President Ibrahim Boubacar Keita's departure was met with jubilation by anti-government demonstrators and alarm by former colonial ruler France, and other allies and foreign nations.

The UN Security Council scheduled a closed meeting Wednesday afternoon to discuss the unfolding situation in Mali, where the UN has a 15,600-strong peacekeeping mission.

Speaking on national broadcaster ORTM just before midnight, a distressed Keita, wearing a mask amid the COVID-19 pandemic, said his resignation -- three years before his final term was due to end -- was effective immediately. A banner across the bottom of the television screen referred to him as the "outgoing president."

"I wish no blood to be shed to keep me in power," Keita said. "I have decided to step down from office."

He also announced that his government and the National Assembly would be dissolved, certain to further the country's turmoil amid an eight-year Islamic insurgency and the growing coronavirus pandemic.

Keita, who was democratically elected in 2013 and reelected five years later, was left with few choices after the mutinous soldiers seized weapons from the armoury in the garrison town of Kati and then advanced on the capital of Bamako. They took Prime Minister Boubou Cisse into custody along with the president.

There was no immediate comment Wednesday from the troops, who hailed from the same military barracks where a coup was launched more than eight years ago, allowing the Islamic insurgency to take hold amid a power vacuum.

The political upheaval unfolded months after disputed legislative elections. And it also came as support for Keita tumbled amid criticism of his government's handling of the insurgency, which has engulfed a country once praised as a model of democracy in the region.

The military has taken a beating over the past year from Islamic State and al-Qaida-linked groups. A wave of particularly deadly attacks in the north in 2019 prompted the government to close its most vulnerable outposts as part of a reorganization aimed at stemming the losses.

Tuesday's developments were condemned by the African Union, the United States, and the regional bloc known as ECOWAS, which had been trying to mediate Mali's political crisis. Former colonizer France and the United Nations, which has maintained a peacekeeping mission in Mali since 2013, also expressed alarm ahead of Keita's speech.

UN Secretary-General Antonio Guterres sought "the immediate restoration of constitutional order and rule of law," UN spokesman Stephane Dujarric said.

But news of Keita's detention was met with celebration throughout the capital by anti-government protesters who first took to the streets back in June to demand that the president step down.

"All the Malian people are tired -- we have had enough," one demonstrator said.

The detention was a dramatic change of fortune for Keita, who seven years earlier emerged from a field of more than two dozen candidates to win Mali's first democratic post-coup election in a landslide with more than 77% of the vote.

Regional mediators from ECOWAS, though, had failed in recent weeks to bridge the impasse between Keita's government and opposition leaders, creating mounting anxiety about another military-led change of power.

Then on Tuesday, soldiers in Kati took weapons from the armoury at the barracks and detained senior military officers. Anti-government protesters immediately cheered the soldiers' actions, and some set fire to a building that belongs to Mali's justice minister in the capital.

Cisse urged the soldiers to put down their arms.

"There is no problem whose solution cannot be found through dialogue," he said in a statement.

But the wheels already were in motion -- armed men began detaining people in Bamako too, including the country's finance minister, Abdoulaye Daffe.

Keita, who tried to meet protesters' demands through a series of concessions, has enjoyed broad support from France and other Western allies. He also was believed to have widespread backing among high-ranking military officials, underscoring a divide between army leadership and unpredictable rank-and-file soldiers.

Tuesday marked a repeat of the events leading up to the 2012 coup, which unleashed years of chaos in Mali when the ensuing power vacuum allowed Islamic extremists to seize control of northern towns. Ultimately a French-led military operation ousted the jihadists, but they merely regrouped and expanded their reach during Keita's presidency into central Mali.

Keita's political downfall closely mirrors that of his predecessor: Amadou Toumani Toure was forced out of the presidency in 2012 after a series of punishing military defeats. That time, the attacks were carried out by ethnic Tuareg separatist rebels. This time, Mali's military has sometimes seemed powerless to stop extremists linked to al-Qaida and IS.

Back in 2012, the mutiny erupted at the Kati military camp as rank-and-file soldiers began rioting and then broke into the camp's armoury. After grabbing weapons, they later headed for the seat of government under the leadership of Capt. Amadou Haya Sanogo. Sanogo was later forced to hand over power to a civilian transitional government, which then organized the election Keita won.

Mediators this time around have urged Keita to share power in a unity government. He even said he was open to redoing disputed legislative elections. But those overtures were swiftly rejected by opposition leaders who said they would not stop short of Keita's ouster.

------

Larson reported from Dakar, Senegal. Associated Press Writer Edith M. Lederer at the United Nations contributed to this report.