Sudan’s ruling military council has foiled a coup attempt, a top general has announced on state television, saying that 12 officers and four soldiers have been arrested.

The announcement late on Thursday closely followed the ruling military and civilian protesters agreeing to end a political impasse, after the army ousted longtime ruler Omar al-Bashir in April on the back of a popular uprising.

“Officers and soldiers from the army and national intelligence and security service, some of them retired, were trying to carry out a coup,” Gen Jamal Omar of the ruling military council said in a statement broadcast live on state television. “The regular forces were able to foil the attempt.” He did not say when the attempt was made.

Omar said of the 12 officers arrested, five were retired, and that security forces were looking for the mastermind of the attempted coup. “This is an attempt to block the agreement which has been reached by the Transitional Military Council and the Alliance for Freedom and Change that aims to open the road for Sudanese people to achieve their demands,” Omar said.

The announcement late on Thursday came as legal advisers of the ruling military council and protest leaders were going through the details of their agreement at a luxury hotel in the capital, Khartoum.

The agreement, which aims to form a joint transitional civilian-military ruling body, was reached last week after intense mediation by African Union and Ethiopian envoys. The forming of the new governing body is the first step towards installing an overall transitional civilian administration in Sudan, as demanded by demonstrators.

Sudan has been rocked by a political crisis since protests first erupted against Bashir’s rule in December. The protests finally led to the army ousting him on 11 April, but the generals who seized power have so far resisted demonstrators’ demands to hand it over to a civilian administration.

Tension had further soared between the two sides after a brutal raid on a longstanding protest camp outside the army headquarters in Khartoum that killed dozens of demonstrators and wounded hundreds more on 3 June.

The raid came after talks between the generals and protest leaders collapsed in May over who should lead the new governing body – a civilian or a soldier. The intervention by African Union and Ethiopian mediators finally led to the agreement reached on the new joint governing body on 5 July.

The agreement proposes a little more than a three-year transition period, with the presidency of the new ruling body to be held by the military for the first 21 months and a civilian for the remaining 18 months.

The ruling body would comprise six civilians, including five from the protest movement, and five officers.