The first quake struck on Saturday in Niigata prefecture, 200km north of Tokyo, followed by strong aftershocks.
It cut off power for 280,000 households, and about 42,000 residents in Niigata were evacuated, Kyodo News and Jiji Press said.
The quake hit as Japan was still reeling from Wednesday's Typhoon Tokage - a ferocious storm that left 79 people dead.
The Kyodo news agency reported that five of the dead had been buried alive, and that aftershocks had rumbled on more than 13 hours after the quake.
The initial tremor measured 6.8 on the Richter scale.
The Japan Meteorological Agency warned of more tremors.
Eight carriages of a high-speed bullet train were derailed near Nagaoka, but there were no injuries, a Transport Ministry official said.
The quake and aftershocks also shook buildings in Tokyo, but there were no reports of any injuries or major damage in the capital.
Japan is vulnerable to earthquakes, accounting for about 20% of the world's tremors of magnitude six or greater.
In 1995, a powerful tremor in the western city of Kobe killed more than 6400 people.