DURRES, Albania — Albania’s strongest earthquake in decades struck early Tuesday, leaving at least 18 people dead and more than 600 injured while setting off a race to find victims buried under the rubble.

The 6.4-magnitude quake struck in the middle of the night and destroyed several buildings in this coastal city. Slightly farther from the epicenter, in the capital, Tirana, the temblor opened cracks in apartments and prompted people to flee into the streets in panic.

The Associated Press, citing Albania’s Defense Ministry, said that seven bodies were pulled from the rubble in Durres and that five people died in the hard-hit town of Thumane. In another town, one person died after jumping from his home in an attempt to escape.

The U.S. Geological Survey said the earthquake caused tremors throughout the Balkans and into southern Italy. Its epicenter was along Albania’s western coast, just north of Durres. The earthquake struck just before 4 a.m. and originated from a fairly shallow depth, just 12 miles underground. Shallow quakes tend to cause more damage than deeper ones, because their waves lose less energy before reaching the surface.

President Ilir Meta said on Twitter that the situation was “dramatic” in Thumane and that everything must be done to save people “stuck under the ruins.”

A government spokesman said that more than 300 people have received medical help at hospitals in Tirana and Durres.

Videos on social media showed collapsed and damaged buildings, cars demolished by rubble and cracks in sidewalks. Rescue teams waded through rubble, carrying stretchers, as volunteers mounted their own efforts.

“The relief of any life saved does not lessen the pain of lost lives and tremendous pity for families who weep for their lost,” Prime Minister Edi Rama said.

In Durres, about 20 miles to the west of Tirana, emergency crews dug through the rubble of a collapsed six-story apartment building — a pocket of disaster in the middle of gray Communist-era buildings that survived the quake. One neighbor, who declined to give his name, called the scene an “apocalypse.”

By midday, a crowd had gathered around the building, believing that at least one person was trapped under the rubble. Some witnesses said the woman had been trying to flee the building with her child. “The door collapsed on her as she was rushing out with her 6-year-old daughter,” said Redona Kapexhiu, who identified herself as a family friend.

As the emergency crews cleared concrete blocks and cut through metal with electric iron saws, onlookers cried and smoked cigarettes.

The Albanian teams were joined in the afternoon by Kosovo police and a special Italian emergency team, which cut a hole through the rubble to send the mother a small oxygen tank.

Local police later said that the mother was rescued but that her child was found dead.

In Durres, at least three buildings had collapsed completely, including a hotel and a Byzantine tower, while dozens of other apartments and houses suffered serious damage. Electricity was knocked out, and schools were closed for the day.

Three aftershocks, with magnitudes between 5.1 and 5.4, followed the initial quake. Another earthquake, with a recorded magnitude of 5.4, was reported to the north in Bosnia.

“Our country was hit by a wave of earthquakes like never before in the darkness of the early hours of today!” Albania’s Meta said in a statement. “It is important to work with dedication and professionalism to save every human life under the rubble of buildings and to help the injured. It is important to identify residents who cannot return to their homes and who need housing.”

Italy, Greece and Turkey were among the countries offering to assist in the rescue work.

Albania is one of Europe’s poorest countries and has been in long discussions to join the European Union.

It was the second time in two months that Albania had been hit by a significant earthquake. In September, a 5.6-magnitude temblor hit roughly the same area and caused dozens of injuries. It was said to be Albania’s most powerful earthquake in 30 years.

Harlan reported from Rome.