Experts were divided over whether the quake would affect Merapi, but there are reports of heightened activity at the volcano. There was an eruption soon after the quake which sent debris some 3.5km (2 miles) down its western side.

Officials said that although the area affected was coastal there was no tsunami resulting from the quake.

The quake hit at 0554 local time (2253 GMT Friday), around 25km (15 miles) south of the city of Yogyakarta, the US Geological Survey (USGS) said.

Yogyakarta, Indonesia's ancient royal capital and one of its biggest cities, is about 440km (275 miles) south-east of the capital, Jakarta.

"The earthquake was felt to be massive - larger than the locals here say they've felt in their lives," said Brook Weisman-Ross, regional disaster co-ordinator for Plan International children's charity in Java.