A tsunami warning has been issued after a magnitude 6.8 earthquake struck off the Indonesian island of Java, swaying buildings as far away as the capital.

Indonesia’s disaster mitigation agency said residents on the Banten coast should “immediately evacuate to higher ground”.

The United States Geological Survey (USGS) said it was centered 151km (94 miles) from Banten province, off the island’s southwest coast, and hit at a depth of 42.8km (26.5 miles).

Buildings in Jakarta swayed for nearly a minute during the evening quake.

TV footage showed workers running out of high-rise buildings and offices.

Radio and TV reports said people felt the strong quake in Banten province and in Lampung province along the southern part of Sumatra island.

People flee after 6.8 magnitude earthquake hits Java: In pictures Show all 6 1 /6 People flee after 6.8 magnitude earthquake hits Java: In pictures People flee after 6.8 magnitude earthquake hits Java: In pictures Villagers wait on higher ground after evacuating when a strong earthquake hit Pasaran Island in Indonesia on August 2 AFP/Getty People flee after 6.8 magnitude earthquake hits Java: In pictures Workers use an emergency exit of a building following an earthquake in Jakarta, Indonesia on August 2 Reuters People flee after 6.8 magnitude earthquake hits Java: In pictures A wall of a villager's house is collapsed after a strong earthquake hit Sukasari village in Indonesia on August 2 AFP/Getty People flee after 6.8 magnitude earthquake hits Java: In pictures People gather outside of an office building following an earthquake in Jakarta, Indonesia on August 2 Reuters People flee after 6.8 magnitude earthquake hits Java: In pictures Villagers wait on higher ground after evacuating when a strong earthquake hit Pasaran Island in Indonesia on August 2 AFP/Getty People flee after 6.8 magnitude earthquake hits Java: In pictures Villagers wait on higher ground after evacuating when a strong earthquake hit Pasaran Island in Indonesia on August 2 AFP/Getty

The temblor caused a panic among residents in several cities and villages, but there were no immediate reports of injuries or damage.

The quake could also be felt in other cities such as Yogyakarta on Java island.

“It was so scary,” said Gustiani Pratiwi, who was carrying two children near an apartment block in Jakarta when she felt the quake strongly.

Last year, a tsunami hit the city of Palu in Sulawesi island, killing thousands, while a crater collapse at the Anak Krakatau volcano triggered a tsunami that killed at least 430 people in an area near the latest quake.

At Carita beach in Banten, which was affected by the Anak Krakatau quake, a resident described the alarm in the area.

“We are panicking a lot,” Sandi, a resident of Carita beach, told Metro TV by telephone.

Support free-thinking journalism and attend Independent events