Egypt on Thursday had a new president, its former president sat in military custody, the top official of the Muslim Brotherhood was under arrest, and at least four television stations had been shut down — all seemingly undemocratic steps barely a year after the nation’s first free and fair presidential elections.

But none of that deterred the feeling of jubilation that remained on the streets in Egypt’s capital, one day after the top military commander ousted Mohammed Morsi from the presidency, suspended a controversial constitution that had been approved in a referendum and called for new presidential elections.

For many here, the dramatic shift in Egypt’s leadership was a culmination of a maelstrom that took months to develop as an increasingly disgruntled public, the nation’s military and Morsi’s incompetent leadership collided. Even as they quietly mulled whether Morsi might have been right that remnants of the government of Hosni Mubarak were constantly undermining him, many here embraced the result.

A popular referendum on the streets had nullified the elections that led to Morsi’s increasingly unpopular and divisive tenure, they said. The military, the last remaining revered national institution, simply carried out the will of the majority, they said. Morsi, they said, had never had control of the government, the final evidence coming when police officers and soldiers turned against him.

“It was a coup, but it was necessary,” said Marwa Abdel Majeed, a businesswoman who felt the military intervention was the only means to spare Egypt from Morsi’s incompetency and divisiveness.

“We were not ready for democracy,” she said, asserting that Egypt’s largely illiterate population was unaware of what elections could bring.

With Morsi’s ouster, the nation now was in the hands of two relatively unknown leaders.

Abdel-Fatah el-Sissi, the defense minister and head of the Supreme Council of the Armed Forces, has been at the post for less than a year, appointed by Morsi last August. Adly Mansour, 67, took the oath office Thursday as acting president, just three days after being named the head of the country’s Supreme Constitutional Court, a post he’ll retain while president.

Military officials arrested the Muslim Brotherhood’s supreme leader, Mohamed Badie, whisking him from his home in the western coastal town of Marsa Matrouh and bringing him to Cairo, where he was charged with inciting violence.

The arrest of Badie was a dramatic step, since even the regimes of Mubarak and his predecessors had been reluctant to move against the group’s top leader. The Brotherhood was banned for most of its 83-year existence, but it has been decades since its general guide was put in a prison.

Authorities have also issued a wanted list for more than 200 Brotherhood members and leaders of other Islamist groups. Among them is Khairat el-Shater, another deputy of the general guide who is widely considered the most powerful figure in the Brotherhood.

The warrant against Badie and el-Shater cited suspicion they were responsible in the killing of six protesters during clashes this week at the headquarters of the Muslim Brotherhood. The deaths came when gunmen inside the building opened fire on protesters attacking the building with stones and firebombs.

The sweep Thursday against the Brotherhood, which remains a powerful political force with a highly organized membership nationwide, raises deep questions over how Islamists will fit into a new political system. Reeling from what it called a military coup against democracy, the group said it would not work with the new political system once in place.

“We declare our complete rejection of the military coup staged against the elected president and the will of the nation,” the Brotherhood said in a statement that the group’s senior cleric Abdel-Rahman el-Barr read to Morsi’s supporters staging a days-long sit-in in Cairo. “We refuse to participate in any activities with the usurping authorities,” it said.

The top opposition political grouping, the National Salvation Front, also issued a statement Thursday saying, “We totally reject excluding any party, particularly political Islamic groups.”

There are fears of a violent backlash from Islamists against the army, particularly from hard-liners, some of whom belong to former armed militant groups. Clashes between Islamists and police erupted in multiple places around the country after the army’s announcement of Morsi’s removal Wednesday night, leaving at least nine dead.

Morsi has been detained in an unknown location since the generals pushed him out Wednesday, and at least a dozen of his senior aides and advisers are being held in what is described as “house arrest.”

Meanwhile, Tahrir Square remained quiet Thursday for the first time since June 28, when pro- and anti-Morsi rallies defined the national landscape, drawing an estimated 14 million Egyptians — overwhelmingly opposed to Morsi — to the streets.

As Mansour read the presidential oath, there was a lull in a nation politically exhausted from first days of tension as they awaited word from the military on what would happen, then from hours of partying that began Wednesday night and lasted until dawn.

But the divisions that have roiled Egypt for months are expected to return today, the start of Egypt’s weekend and the day when demonstrations are common.