After nearly 30 years in power, Sudan's President Omar al-Bashir has been ousted and arrested, the defence minister says.
Speaking on state TV, Awad Ibn Ouf said the army had decided to oversee a two-year transitional period followed by elections.
He also said a three-month state of emergency was being put in place.
Protests against Mr Bashir, who has governed Sudan since 1989, have been under way for several months.
The main group behind the demonstrations immediately rejected the military's statement and urged people to remain at a sit-in outside army headquarters.
Protesters want a civilian council to lead the transition rather than a military one, correspondents say.
"I announce as minister of defence the toppling of the regime and detaining its chief in a secure place," Mr Ibn Ouf said in a statement.
Mr Bashir's exact whereabouts are not known.
Mr Ibn Ouf said the country had been suffering from "poor management, corruption, and an absence of justice" and he apologised "for the killing and violence that took place".
He said Sudan's constitution was being suspended, border crossings were being shut until further notice and airspace was being closed for 24 hours.
As the news broke, crowds of protesters celebrated outside army headquarters in the capital, Khartoum, embracing soldiers and climbing on top of armoured vehicles.
Sudan's intelligence service said it was freeing all political prisoners.
Mr Bashir is the subject of an international arrest warrant issued by the International Criminal Court (ICC), which accuses him of organising war crimes and crimes against humanity in Sudan's western Darfur region.
However, it is not clear what will happen to him following his arrest.
How did the coup unfold?
Early on Thursday, military vehicles entered the large compound in Khartoum housing the defence ministry, the army headquarters and Mr Bashir's personal residence.
State TV and radio later interrupted programming to say the army would be making a statement.
Meanwhile, tens of thousands of demonstrators marched through central Khartoum, some chanting: "It has fallen, we won."
How have protesters reacted?
The SPA said the military had announced a "coup" that would merely reproduce the same "faces and institutions that our great people revolted against".
It urged people to continue the sit-in outside military headquarters and to stay on the streets of cities across the country.
"Those who destroyed the country and killed the people are seeking to steal every drop of blood and sweat that the Sudanese people poured in their revolution that shook the throne of tyranny," the statement read.
The SPA has previously said that any transitional administration must not include anyone from what it called the "tyrannical regime".
A young woman who became a symbol of the protests also dismissed the military announcement.
Alaa Salah, nicknamed "Kandaka" or "Nubian queen" after she was filmed leading chants against the government, accused the authorities of "hoodwinking" the people.
The protests were originally sparked by a rise in the cost of living, but demonstrators then began calling for the president to resign and his government to go.
Government officials said 38 people had died since December but Human Rights Watch said the number was higher.
In February, it looked as though the president might step down, but instead Mr Bashir declared a state of national emergency.
What other reaction has there been?
UN Secretary-General Antonio Guterres appealed for "calm and utmost restraint by all" and urged a transition that would meet the "democratic aspirations" of the people.
The UN Security Council is to discuss the situation in a closed-door meeting on Friday called by the US, France, Britain, Germany, Belgium and Poland, diplomats said.
UK Foreign Secretary Jeremy Hunt said that a two-year military council was "not the answer".
"We need to see a swift move to an inclusive, representative, civilian leadership. And we need to ensure there's no more violence," he said on Twitter.
The African Union condemned the military takeover. AU Commission chairperson Moussa Faki Mahamat said it was not an appropriate response to the challenges facing the country and the aspirations of its people.
Russia, which has twice hosted Mr Bashir, called for calm and said it was monitoring the situation.
Presidential spokesman Dmitry Peskov expressed hope that bilateral ties would not be damaged, whoever was in power.
Amnesty International's Secretary General Kumi Naidoo praised the courage of the Sudanese people but said he was "alarmed by the raft of emergency measures" announced by the military.
In a statement, he also said that justice was "long overdue" for Mr Bashir.
"Omar al-Bashir is wanted for some of the most odious human rights violations of our generation and we need to finally see him held accountable," Mr Naidoo added.
Who is Omar al-Bashir?
Formerly an army officer, he seized power in a military coup in 1989.
His rule has been marked by civil war. The civil conflict with the south of the country ended in 2005 and South Sudan became independent in 2011.
Another civil conflict has been taking place in the western region of Darfur. Mr Bashir is accused of organising war crimes and crimes against humanity there by the ICC.
Despite an international arrest warrant issued by the ICC, he won consecutive elections in 2010 and 2015. However, his last victory was marred by a boycott by the main opposition parties.
The arrest warrant has led to an international travel ban. However, Mr Bashir has made diplomatic visits to Egypt, Saudi Arabia and South Africa.
- BBC / Reuters