VOUZELA, Portugal - At least 31 people have died in fires ravaging forests in northern and central Portugal over the past 24 hours, rescuers said Monday afternoon, after three people were killed in Spain in blazes sparked by arsonists and fanned by Hurricane Ophelia. In Portugal, Prime Minister Antonio Costa declared a state of emergency as some 5,000 firefighters fought some 30 major fires. The 31 deaths, confirmed by Portugal's national civil protection agency, come four months after 64 people were killed and more than 250 injured on June 17, in the deadliest fire in the country's history.

Even before the latest blazes, nearly 216,000 hectares (530,000 acres) had been consumed by wildfires across the country between January and September, according to estimates from the country's forest service.

The 524 registered outbreaks of fire, by far the most since 2006, were caused by "higher than average temperatures for the season and the cumulative effect of drought," civil protection agency spokeswoman Patricia Gaspar said.

51 people have been wounded in the fires, 15 seriously, Gaspar told AFP.

One of the worst hit areas is near Lousa, in the Coimbra region, where 650 firefighters are battling blazes.

"We went through absolute hell, it was horrible. There was fire everywhere," a resident of the town of Penacova told RTP television.

Two brothers in their 40s who were trying to put out the blaze there were among the fatalities.

In a village in the commune of Vouzela, in the northern district of Viseu, residents used water hoses to try to fight the flames as several homes were consumed, an AFP reporter saw.

Fallen electricity pylons and abandoned cars were left lying in roads, the area surrounded by burnt pine and eucalyptus trees, as thick smoke clogged the sky.

"Most of the victims were killed in their cars, but we also found them inside their houses," said the mayor of the town of Oliveira do Hospital, Jose Carlos Alexandrino, on public television RTP.

"The whole city looked like a ball of fire, surrounded by flames on all sides," he said.

In the northwestern Spanish region of Galicia, on the Portuguese border, Prime Minister Mariano Rajoy blamed arsonists for most of the deadly wildfires, which have caused three deaths.

"What we are experiencing here does not happen by chance, this was provoked," he said after observing a minute's silence for the victims in the town of Pazos de Borben.

He said a major wildfire broke out near the town in the early hours of Sunday in five different locations at the same time.

Hundreds of firefighters backed by water-dropping helicopters and planes were battling 19 large wildfires in Galicia on Tuesday, the regional government said in a statement.

"Galicia is not burning by itself. Galicia is being burned," said Alberto Nunez Feijoo, head of the regional government, blaming "terrorist arsonists".

Five wildfires near Vigo, Galicia's biggest city, forced the evacuation of a shopping mall and a PSA Peugeot Citroen factory on the outskirts of the city, though workers were able to return to the factory on Monday.

The city of around 300,000 residents has opened up two sports centres and booked rooms in three hotels for people who had to evacuate their homes.

At least 10 schools cancelled classes on Monday in Vigo because of the flames, local officials said.

Two women also died on Sunday after being engulfed in flames trapped in their van near Nigran, outside Vigo, and an elderly man died in an animal shed near his house in Carballeda de Avia.

The national weather office forecast rain and cooler temperatures in Galicia starting Monday, which officials hope will help put out the flames.

Hurricane Ophelia swept past Spain before being downgraded to a violent storm on Monday as it battered Ireland.

Meteorologists said Ophelia was the most powerful hurricane recorded so far east in the Atlantic and the first since 1939 to travel so far north.