TOKYO - An earthquake with a preliminary magnitude of 5.8 rattled Japan's northernmost main island of Hokkaido early Sunday, the weather agency said.