CAIRO -- Over recent years, Sudan鈥檚 military and a separate armed force accumulated power, each suspicious of the other, even as they worked together against the country鈥檚 pro-democracy movement. Officers inside both forces say it was a long-building recipe for disaster.

Their tenuous alliance ended in mid-April, when they turned their guns on each other, sparking a conflict that threatens to engulf African鈥檚 third largest country.

In interviews with The Associated Press, more than a dozen senior officers from Sudan鈥檚 military and the rival paramilitary known as the Rapid Support Forces described what led them to an all-out war. They, along with political activists and a U.N. official, recounted how both sides made power grabs, shifted alliances and moved to protect their interests under international pressure for a transition to civilian government.

All spoke on the condition of anonymity for fear of reprisal or because they were not authorized to speak to the media. Neither the RSF nor the military responded to requests for comment.

It was Sudan鈥檚 strongman and former president, Omar al-Bashir, who created the RSF out of Darfur鈥檚 notorious Janjaweed militias in 2013. For al-Bashir, the RSF and the regular military were both useful in suppressing dissent and bids for independence by minority communities around the country. By keeping the two forces independent of each other, he also ensured that no one figure held enough power to overthrow him,

That changed when a popular protest movement against Bashir arose in 2019. The head of the military, Gen. Abdel Fattah Burhan, and RSF leader Gen. Mohammed Hamdan Dagalo decided it was time for the president鈥檚 30-year-rule to end. They mounted their first of two coups together.

Together, they also formed a bulwark against the pro-democracy movement. Weeks after al-Bashir鈥檚 ouster, RSF forces led the storming of the protesters鈥 sit-in in central Khartoum, killing at least 120 people and raping dozens of women.

The paramilitary鈥檚 head, Dagalo, started to expand his influence. He built up significant wealth, controlling gold mining operations in Darfur鈥檚 Jebel Amer and other parts of the country in cooperation with Russia's Wagner mercenary group.

The RSF recruited thousands of new troops, purchased new weapons and set up its own parallel bases in most of the country鈥檚 provinces. The army鈥檚 command was unhappy that it was done 鈥渕ostly without coordination with the military鈥檚 leadership,鈥 one member of the military鈥檚 top governing council told the AP.

That鈥檚 when there were first signs of the already fraught relationship starting to unravel.

Career officers in the military began to press their leadership to curb the growing power of the RSF, several military officials said. The higher salaries of many RSF fighters fueled resentment.

In September 2021, a military unit based just outside the capital staged a small-scale mutiny. The military, with the RSF鈥檚 help, crushed the attempt. It served as a reminder of the paramilitary's strength. Afterwards Burhan received internal reports showing that a majority of officers wanted the paramilitary dissolved.

Some refused to salute Dagalo, one military official said. 鈥淭hey would say, 鈥楬e is not a real officer鈥,鈥 he recounted.

But Burhan and the military leadership still needed the RSF amid pressure for a democratic transition. As a deadline to hand power to civilians approached, Burhan and Dagalo on Oct. 25, 2021, joined forces to lead their second coup, removing the government of Prime Minister Abdalla Hamdok.

Now effectively joint rulers of Sudan, the gap between them only widened.

RSF attempts to build its own air force severely strained the relationship, officials from both sides said. The paramilitary tried to recruit officers and technicians from within the air force's ranks, according to the military officials.

In a March 2022 meeting, Burhan sharply told Dagalo that the military 鈥渨ill not allow any air force outside its control,鈥 according to an official who attended the meeting. Dagalo replied that he had abandoned the idea, but Burhan countered with evidence of recent recruiting attempts, the official said.

Dagalo decamped to Darfur for two months to get away from his military counterpart, an RSF official said.

There, he was alarmed by military attempts to weaken the RSF鈥檚 grip over its stronghold of Darfur. He found that military leaders had designs for a new border guard force in coordination with militia leader Musa Hilal, a longtime foe of Dagalo, according to military and RSF officials.

Dagalo considered it 鈥渁 stab in his back,鈥 an official from his inner circle said.

Meanwhile, international calls for the generals to sign a roadmap for a transition to civilian rule grew louder. American pressure on Saudi Arabia and the United Arab Emirates to withhold badly needed financial aid was crucial in forcing them to bow, said a former official from the coup-ousted government who remained close to both camps.

鈥淭hey were pushed to a corner,鈥 he said.

Dagalo tried to whitewash his image. He declared the coup a mistake and portrayed himself as a supporter of demands for civilian rule. He allied with the Forces of Freedom and Change, the main umbrella group of pro-democracy organizations.

鈥淚t was an alliance of convenience," said a political figure who has been involved in negotiations with the generals. For the FCC, Dagalo was a counterbalance to Islamists in the military, he said.

Burhan and other military commanders were furious, feeling that Dagalo had betrayed them.

Dagalo 鈥渢ried to save himself on the expense of the military," a senior military official close to Burhan said.

In December, the military, RSF and the pro-democracy groups reached an initial deal promising a transition to civilian rule.

One of its key provisions 鈥 that the RSF be incorporated into the military 鈥 proved the final wedge between them.

The military wanted the merger to take place within two years, the deadline for elections to be held, and demanded the RSF answer to the head of the military.

The RSF demanded a 10-year period for integration, during which the entire security establishment would be overhauled. The RSF also wanted to report to the head of state.

In the following months both sides poured forces into and around Khartoum as rhetoric escalated. Altogether, there were more than 200,000 soldiers in the Khartoum area, said Mariam al-Mahdi, a former minister in the deposed civilian government.

Deadlines to sign a final political deal were repeatedly pushed back. Close observers warned an open conflict was possible.

On April 13, the RSF deployed forces closer to a military air base in the northern town of Meroe, where Egyptian troops were conducting an exercise with the Sudanese military, according to Egyptian authorities. The military denounced the deployment. International diplomats rushed to de-escalate, fearing shots could be fired.

On the morning of April 15, clashes erupted at Khartoum鈥檚 Sports City, a decades-old, incomplete athletics complex where both the RSF and military had bases. Each accused the other of firing first as part of a desperate power grab.

Within hours, millions of Sudanese were pinned down under fire, as the two forces battled in the streets of Khartoum and other cities, and warplanes blasted RSF bases.

鈥淲e all saw the enormous tensions and we all saw ... that any single spark, even though unintended, could lead to an outbreak of hostilities,鈥 Volker Perthes, the U.N. envoy for Sudan, told the AP. 鈥淚n the end, it was a power struggle between the two military leaders.鈥