Indonesia's national disaster agency warned the quake could generate a tsunami as high as three metres.

Five people died and several were injured after a powerful undersea earthquake rocked Indonesia's heavily populated Java island, triggering a brief tsunami warning, the national disaster agency said Saturday.

The 6.9 magnitude quake on Friday evening sent residents fleeing to higher ground, while many in the capital Jakarta ran into the streets.

An official from Indonesia's national disaster agency warned the quake could generate a tsunami as high as three metres (10 feet), but the alert was lifted several hours later.

Three people died of heart attacks as the strong quake rocked the region, agency spokesman Agus Wibowo said on Saturday.

Another person fell to his death while trying to flee his house when the jolt happened, he said, while a fifth victim died from a panic attack.

Four more people were injured and more than 200 buildings were damaged, with about 13 houses destroyed, he added.

More than 1,000 people, who had earlier fled to temporary shelters, returned home after authorities convinced them it was safe to do so, Wibowo said.

"There was thundering noise -- it sounded like a plane overhead -- and I was just so scared that I ran," said 69-year-old Isah, who like many Indonesians goes by one name, at an evacuation shelter in Pandeglang at the southwest end of Java.

In December, the area was hit by a volcano-sparked tsunami that killed more than 400 people.

Indonesia experiences frequent seismic and volcanic activity due to its position on the Pacific "Ring of Fire", where tectonic plates collide.

Last year, a 7.5-magnitude quake and a subsequent tsunami in Palu on Sulawesi island killed more than 2,200 people, with another thousand declared missing.

On December 26, 2004, a 9.1-magnitude earthquake struck off the coast of Sumatra and triggered a tsunami that killed 220,000 across the Indian Ocean region, including around 170,000 in Indonesia.