Rival factions of Sudan’s military have agreed to renew a three-day ceasefire, shortly before it was due to expire.

The extension – for another 72 hours – follows intensive diplomatic efforts by neighbouring countries, as well as the US, UK, and UN.

But there are continuing reports of heavy fighting in the capital Khartoum.

The previous truce allowed thousands of people to attempt to flee to safety, while dozens of countries have tried to evacuate their citizens.

Almost two weeks of fighting between the army and a rival paramilitary group have left hundreds dead.

The ceasefire had been expected to end at midnight local time (22:00 GMT).

Early on Thursday evening the Sudanese regular army agreed to an extension, and its rival the paramilitary Rapid Support Forces (RSF) followed suit hours later.

South Sudan has offered to host peace talks, and the army has agreed to send representatives to the talks.

US Secretary of State Antony Blinken said Washington was “very actively working” to extend the truce, adding that while imperfect it had reduced violence.

But White House spokeswoman Karine Jean-Pierre later said the situation could worsen at any moment.

Meanwhile, the RSF and eyewitnesses said the army had been pounding its positions in Khartoum.

The foreign minister of the civilian government, Maryam al-Sadiq al-Mahdi, told the BBC from her home in Khartoum that despite the ceasefire, civilians were still living in fear.

“What they call a truce has nothing to do with what is happening,” she told Radio Four’s World Tonight program. “The bombardment by the aeroplanes is taking place almost all day and night.”

Fighting has also been reported in the western Darfur region and other provinces.

At least 512 people have been killed in the fighting and almost 4,200 injured, although the real number of deaths could be much higher.

The World Health Organization said it expected there to be “many more” deaths due to outbreaks of disease and a lack of services.

Health officials say most hospitals in conflict areas are not functioning, and more than 60% of health facilities in Khartoum are inactive.

David Miliband, the head of the International Rescue Committee and former British foreign secretary, said the international community was in danger of neglecting the wider crisis in Sudan in the rush to evacuate foreign nationals.

“The fact that for the last ten days, pretty much all the media coverage and the vast bulk of political attention has been on getting out thousands of people and not on the need to tend to millions of people sticks in the gullet,” he told the BBC.

“Of course the lives of the thousands who need to evacuate are important, but what about the 45 million who are left?

“Sudan’s population has 15 million people in humanitarian need and I think part of our call today as the International Rescue Committee is to say let’s not fall into that trap of thinking that once thousands are evacuated the problem is solved.”

An army statement quoted by Reuters news agency said it had taken control of most of Sudan’s regions but “the situation is a bit complicated in some parts of the capital”.

It has not been possible for the BBC to verify the army’s claims.

Foreign nations, including the UK, have been urging their citizens to leave the country as soon as possible.

Speaking on Thursday evening, Ms. Jean-Pierre urged Americans to depart within the next 24 hours.

Evacuations are continuing, but many foreigners are still stuck in Sudan. Some have struggled to get to the airstrip used for evacuations.

Local civilians are continuing to flee the capital, where there are problems with supplies of food, water, and fuel.

The fighting broke out on 15 April as the result of a bitter power struggle between the regular army and RSF.

Army commander Gen Abdel Fattah al-Burhan and RSF chief Gen Mohamed Hamdan Dagalo, better known as Hemedti, disagree about the country’s proposed move to civilian rule, and in particular about the timeframe of the 100,000 strong RSF’s inclusion into the army.

Both factions fear losing power in Sudan because on both sides there are men who could end up at the International Criminal Court for war crimes committed in Darfur almost 20 years ago.