Water pipes at the city's train station burst and rail traffic was briefly suspended. Schools along the east coast were evacuated, with students holding their backpacks over their heads for protection. TV news showed at least one landslide in a lightly populated area.
Officials said a total of 17 people were injured, mostly by falling objects inside buildings. However, two hikers in the famed Taroko Gorge national park, including one from Malaysia, were injured by falling rocks, the Hualien government reported.
Traffic through the gorge has been halted while drones and helicopters check for damage, Premier Su Tseng-chang said. "If it rains, (retaining walls) could fall down, so we urge people not to get close," he said.
Su said schools, worksites and water, power and transit lines had also been checked for damage. While no major problems were found, cracked road surfaces on the east coast could become a problem if rain falls soon, he said.
In Taipei, about 115 kilometers (70 miles) from the epicenter, people felt buildings shake, and one multistory building was leaning against its neighbor after its foundation shifted. The city's subway system suspended service.
At the leaning building in downtown Taipei, area resident Ayumi Lin said the earthquake's force was considerable. "It was really scary," Lin said. "The quake shook strongly twice." The owner of a travel agency in the adjacent building, who gave only his surname, Huang, said all his employees evacuated safely from their 7th floor office. "No one was hurt," Huang said.
People in Chinese cities close to the Taiwan Strait dividing Taiwan from mainland China reported on social media that they also felt the quake. Taiwan is on a string of seismic faults around the Pacific Ocean known as the "Rim of Fire" and is frequently rocked by tremors, including a 1999 quake that killed more than 2,300 people.
An earthquake in February 2018 in Hualien killed 17 people when four buildings partially collapsed. Two years earlier, an apartment building in the southwestern city of Tainan collapsed in an earthquake, killing 115 people.
The government has set up an elaborate system of alerts, inspections and recovery measures to cope with the frequent quakes. Hao Yilin, an exchange student from China studying at Chinese Culture University in Taipei, said he received a notice on his cellphone seconds before the ground began to shake.
"I wasn't scared because an earthquake like this is very common and the shaking was tolerable. So I didn't think of going outdoors and continued to eat lunch while watching a TV series," Hao said.