TOKYO—Some people in Tokyo were warned that a major earthquake was about to hit before they felt a tremor.

As the 8.9-magnitude earthquake struck Japan's northeastern coast, the world's first early warning system—developed by the country's meteorological agency—detected the quake's shock wave near the seismic center and sent off the warning message, which appeared on national television and radio as well as cellphone screens.

In...