TAIPEI, Taiwan -- A 6.4-magnitude quake on the east coast of Taiwan has left two dead and more than 200 injured, the government said, after buildings crumbled and trapped people inside.

A hotel and an apartment block were the worst hit by the quake in the port city of Hualien, according to the national fire agency.

Five more buildings including a hospital have also been damaged with roads strewn with rubble, cracks along highways and damaged buildings tilted at angles.

The worst-hit Marshal Hotel partly crumpled into the ground, leaving it slanting on its side, as rescuers on cranes attempted to free people from its upper floors.

A large hotel in Taiwan`s northeastern city of Hualien has partially collapsed after a 6.4 Magnitude earthquake late Tuesday night. (AFP)

"It's the biggest quake I've experienced in Hualien in more than 10 years," resident Blue Hsu told AFP, who said his home shook violently.

Describing the scene at the hotel, Hsu said its bottom storeys had been crushed.

"The lower floors sunk into the ground and I saw panicked tourists being rescued from the hotel," he said.

Hualien is one of Taiwan's most popular tourist hubs as it lies on the picturesque east coast rail line and is near to popular Taroko Gorge.

Facebook user Sun Chen-hsiang, who was livestreaming the scene at the hotel from a distance, told how the building next to his home had also collapsed.

"All the people watching this livestream, please get yourself to a safe place and don't stay home," he said.

Another resident told AFP how an apartment block near his flat had also partially collapsed.

A large hotel in Taiwan`s northeastern city of Hualien has partially collapsed after a 6.4 Magnitude earthquake late Tuesday night. (AFP)

"I saw the first floor sink into the ground. Then it sunk and tilted further and the fourth floor became the first floor," said Lu Chih-son, 35, adding he saw 20 people rescued from the building.

"My family were unhurt, but a neighbour was injured in the head and is bleeding. We dare not go back home now. There are many aftershocks and we are worried the house is damaged."

There had been at least 15 aftershocks following the quake, Taiwan's weather bureau said.

- Quake anniversary -

Officials from Hualien fire department said 149 people had been rescued from damaged buildings.

Authorities said some people remained trapped but were unable to give an overall figure.

Rescuers from around the island were preparing to help, Taiwan's president Tsai Ing-wen said on her Facebook page, promising rapid disaster relief.

The quake hit at 23:50 pm (1550 GMT) around 21 kilometres (13 miles) northeast of Hualien, according to the United States Geological Survey.

It follows almost 100 smaller tremors to have hit the area in the last three days and comes exactly two years since a quake of the same magnitude struck the southern Taiwanese city of Tainan, killing more than 100 people.

Most of the deaths from the February 2016 earthquake were from the 16-storey Wei-kuan apartment complex, which toppled on its side with many of its residents buried in the rubble.

It was the only high-rise in Tainan to crumble completely in the quake, which came two days before Lunar New Year, when many people would have been visiting relatives for the biggest celebration of the Chinese calendar.

The safety of the building was called into question immediately after the disaster, when metal cans and foam were found to have been used as fillers in the concrete and residents said there had been cracks in the structure.

Five people were found guilty and sentenced to five years imprisonment over the disaster, including the developer and two architects, with prosecutors saying they "cut corners" that affected the building's structural integrity.

Taiwan lies near the junction of two tectonic plates and is regularly hit by earthquakes.

The island's worst tremor in recent decades was a 7.6 magnitude quake in September 1999 that killed around 2,400 people. (AFP)