CAIRO — Egypt’s first presidential elections since the ouster of longtime ruler Hosni Mubarak will begin on May 23, election officials announced Wednesday.

A new president will be named by June 21, officials said, a timeframe that allows the country’s military rulers to meet their pledge to transfer power to a civilian government by the end of June.

Egypt’s ruling generals took control of the state from Mubarak in February 2011, but their popularity has waned since then. Human rights activists accuse them of committing human rights violations that rival those of Egypt’s former autocrat, who is currently on trial, and working to protect their political and economic privileges.

The military rulers had been hesitant to announce a date for presidential elections and a transition to civilian rule. But after a week of bloody clashes between security forces and anti-military protesters in November, Egypt’s top general and Mubarak-era defense minister, Mohamed Hussein Tantawi, was pushed to declare that the military would give up power by the end of June

While many candidates have already been campaigning for months, the presidential campaign will formally open on April 30 after a final list of candidates is released on April 26.

Egyptians will vote over two days in May, the head of the presidential election commission, Farouk Sultan, said at a press conference. If no candidate garners more than half the vote in that round, the top two candidates would face each other in a runoff on June 16 and 17.

The powers of Egypt’s next president remain unclear. A 100-member assembly, to be named by the new parliament, will be tasked with writing the constitution, which is to be put to the public in a referendum before the president assumes power. Some liberals and activists worry that if the constitution is written while Egypt is under military rule, the generals will try to influence the drafting of the document.