The quake, which knocked out power in several parts of the capital Taipei, hit at 7.58am on Wednesday (local time) at a depth of 15.5km just off the eastern coast of Taiwan, according to Taiwan's Central Weather Administration.
Taiwan's government said four people had died in the mountainous, sparsely populated eastern county of Hualien where the epicentre was. A further 711 people have been injured.
Taiwan television stations showed footage of buildings at precarious angles in Hualien, where the quake struck as people were going to work and school. At least 26 buildings have collapsed, more than half in Hualien. The government said 77 people were trapped.
"It was very strong. It felt as if the house was going to topple," said 60-year-old Taipei hospital worker Chang Yu-Lin.
Video showed rescuers using ladders to help people out of windows, while elsewhere, massive landslides caused by the tremors carved down hillsides.
Japan's weather agency said several small tsunami waves reached parts of the southern prefecture of Okinawa, and later downgraded the earlier tsunami warning to an advisory. It put the quake's magnitude at 7.7.
The Philippines Seismology Agency also issued a warning for residents in coastal areas of several provinces, urging them to evacuate to higher ground.
Taiwan also issued a tsunami warning, but reported no damage from that, and the Pacific Tsunami Warning Center in Hawaii later said the risk of damaging tsunami waves had now largely passed.
Aftershocks could still be felt in Taipei, according to a Reuters witness, with more than 25 registered so far, according to Taiwan's central weather administration.
Chinese state media said the quake was felt in China's Fujian province, while a Reuters witness said it was also felt in Shanghai.
The Taipei city government said it had not received any reports of major damage and the city's metro, the MRT, was up and running soon after the tremor, while electricity operator Taipower said more than 87,000 households in Taiwan were still without power.
Southern Taiwan Science Park, where semiconductor giant Taiwan Semiconductor Manufacturing has a plant, said companies were operating without impact. TSMC said its safety systems are operating normally.
Taiwan's Central Weather Administration said the quake registered the second-highest intensity of an "Upper 6" in Hualien county, on the 1-7 intensity scale.
In an Upper 6 earthquake, most unreinforced concrete-block walls collapse and people find it impossible to remain standing or move without crawling, the Japan Meteorological Agency says.