Madrid (CNN) -- Thousands of residents of the southeastern Spanish city of Lorca slept outside Wednesday night, hours after the city of about 80,000 was struck by an earthquake that killed eight people, state radio reported, citing authorities.
"It was a strange sensation," said a press office worker who was in his office in the regional capital of Murcia, about 60 kilometers (37 miles) from Lorca. He estimated the duration of the quake from five to eight seconds.
The 5.1-magnitude quake occurred at 6:47 p.m. (12:47 p.m. ET) and was centered about 50 kilometers (31 miles) southwest of Murcia, near the Mediterranean coast, the U.S. Geological Survey said. That is about 350 kilometers (218 miles) south-southeast of Madrid.
It was preceded at 5:05 p.m. (11:05 a.m. ET) by a 4.5-magnitude temblor centered in the same area, the survey said.
At least one of the deaths occurred in a building collapse in Lorca, state-run EFE said.
Television pictures showed the belfry of an old church collapsing soon after the earthquake, as well as fallen bricks on top of damaged cars there. Buildings with broken windows and piles of rubble in the streets of Lorca could also be seen.
The press office said a hospital in Lorca had been evacuated as a precaution.
Many of those who were spending the night outside said they were afraid to return to their houses or had been advised not to do so, state radio said.
The quake occurred during an election campaign for Spain's 8,000 town mayors and most of its regional governments, with voting scheduled for May 22. The two major parties called for a suspension of campaigning on Thursday out of respect for the victims.
CNN's Al Goodman and Juan Munoz contributed to this story.