Tens of thousands of people returned to their homes around Madrid on Wednesday after nearly a week of uncertainty, as authorities eased evacuation orders and movement restrictions in areas affected by major wildfires.

Spain's Interior Ministry said restrictions had been lifted for more than 20 communities after conditions improved.

However, authorities warned against declaring victory too soon as the country's fourth heatwave of the summer, forecast to last until Sunday, is expected to hamper firefighting efforts in the coming days.

The situation is evolving "favourably," Prime Minister Pedro Sánchez said during a visit to the emergency command centre in Navalcarnero, near Madrid. He cautioned, however, that the country must remain "extremely vigilant."

Firefighters made further progress against the blazes in western Madrid region and the neighbouring provinces of Ávila and Toledo. Interior Minister Fernando Grande-Marlaska said the fires had not spread further.

He said he hoped crews would be able to begin extinguishing remaining pockets of fire and securing the affected areas on Wednesday.

More than 50,000 people around the Spanish capital have been returning home since Tuesday evening as the situation stabilized. However, about 40,000 people remain subject to evacuation orders or movement restrictions, although emergency officials said they hoped those measures could soon be lifted.

Attention has now turned to a wildfire in the eastern province of Castellón, where the blaze remains out of control. The fire has burned 9,300 hectares of woodland and scrubland near Vall d'Uixó.

Around 16,000 people were evacuated from the area over the weekend, with more than 6,000 now allowed to return home.