National Disaster Mitigation Agency spokesman Sutopo Purwo Nugroho said, a 62-year-old man and an 80-year-old woman were killed in building collapses.

A strong earthquake shook Indonesia’s densely populated Java island on Friday night, killing two people and severely damaging dozens of homes near the epicentre.

The quake struck at 11:47 p.m. and was felt across the island, including about 200 kilometres away in the capital Jakarta, where office towers and apartment buildings swayed. Powerful tremors lasted as much as 30 seconds in places.

Panicking people ran out of buildings in many areas and roads were clogged with motorbikes, cars and trucks as people fled coastal areas.

Residents gather outside their apartment blocks in Jakarta early on December 16, 2017 (local time), after a strong earthquake measuring 6.5 on the Richter scale. | Photo Credit: AFP

A 62-year-old man and an 80-year-old woman were killed in building collapses, said National Disaster Mitigation Agency spokesman Sutopo Purwo Nugroho.

Damage was heaviest in the Tasikmalaya, Pangandaran and Ciamis regions of West Java Province near the epicentre.

More than 40 houses collapsed and about 65 suffered severe damage, said Mr. Nugroho.

Image tweeted by U.S. Geological Survey locates the epicentre of the earthquake that struck Indonesia’s Java Island in Indonesia. Photo: @USGS

The earthquake had a magnitude of 6.5 and was about 91 kilometres (56 miles) deep and located just inland, the U.S. Geological Survey said.

It triggered a tsunami warning for parts of Java’s coastline that was lifted about two hours later.

Several hospitals were damaged by the shaking and patients evacuated.

Indonesia sits on the “Pacific Ring of Fire” and has frequent earthquakes and volcanic eruptions.