There have been no immediate reports of damage.
The quake shook buildings in the capital, Taipei.
The quake had a depth of 24.9 km (15.5 miles), the weather administration said.
Taiwan has been hit by more than 1,000 aftershocks since a 7.2 magnitude quake struck Hualien earlier this month.
The earthquake and its aftershocks killed 17 people.