MADRID — Two earthquakes struck within two hours of each other in southeast Spain on Wednesday, killing at least eight people, injuring scores more and severely damaging some buildings.

Spain is hit by hundreds of quakes a year, but most are too small to be felt. The deadliest recent quake struck in 1956, killing 12 people.

The first quake hit Wednesday afternoon and had a magnitude of 4.5; it was followed by one with a magnitude of 5.1, according to the United States Geological Survey. The epicenters of the quakes were a few kilometers outside the town of Lorca, according to the Spanish National Geographic Institute.

The regional government of Murcia said late Wednesday night that eight people had died and 40 people were taken to the hospital. Thousands of people had also left their homes because of the risk of additional tremors, according to the local government; many spent the night in emergency shelters.