A Spanish man drowned in a failed attempt to rescue a nine-year-old girl who became trapped inside a car during flash flooding in southeastern Spain, a local official said Sunday.

The girl was travelling with her grandfather and 11-year-old brother when their vehicle was caught in rapidly rising flood waters on Friday near the town of Puerto Lambreras, an official with the town hall said.

A 60-year-old man - identified by Spanish media as Juan Asensio - tried to rescue the girl but he was swept away by the flood waters and died, he added.

The girl and her grandfather also drowned but the 11-year-old boy survived, reportedly by holding on to a lamppost.

"Three people died. We are still not sure how the boy managed to survive," said the official with the town hall of Puerto Lambreras who asked not to be named in line with the municipality's policy.

Ten people in total have died in Spain in the regions of Andalusia and Murcia due to flash flooding brought on by downpours. The heavy rains have also damaged homes, caused the collapse of two bridges and forced roads to close.

Hundreds of people - municipal officials and volunteers - worked on Sunday to sweep streets of mud and debris in both regions.

"This is a disaster, an authentic disaster," 75-year-old Antonio Lopez told the online edition of local newspaper La Verdad as he watched the cleanup operation near his home in Puerto Lumbreras.

"The street was like a river. We could not go anywhere. It was incredible," he added.

Some 500 people were evacuated from their homes on Friday after the torrential rains caused rivers to break their banks and flooded roads and railways but the most have since returned home.

The rains drenched the south of the country before moving east and eventually north.