There were no immediate reports of damage or injuries in either country after the quake, which shook office buildings in the Taiwanese capital, Taipei.
The Japan Meteorological Agency issued a warning for a 1-meter tsunami in small islands that are part of Okinawa, including Miyakojima, popular with tourists for diving. There was no warning issued for the main Okinawa island, which hosts U.S. military bases.
The agency later lifted the tsunami warning.
It said a very shallow earthquake with a magnitude of 6.8 had hit near Okinawa at 10:43 (0143 GMT).
Taiwan’s Central Weather Bureau put the epicenter of the quake about 75 km (45 miles) off Taiwan’s eastern coast at a depth of about 17 km (10 miles).
The U.S. Geological Survey identified a single quake, measuring 6.6, hitting 72 km southeast of Su-ao in Taiwan at a depth of about 30 km (20 miles). There are often small discrepancies in quake details reported by different agencies.
The Pacific Tsunami Warning Center said there was no threat of a tsunami after the quake.