TOKYO—Prime Minister Shinzo Abe's surprise visit to a shrine linked to Japan's militarist past threatens to damage ties with the U.S. and jeopardize a pillar of the White House's diplomatic and military pivot to Asia.

The outing to Tokyo's Yasukuni Shrine on Thursday triggered strong criticism from Beijing and Seoul, but also a rare admonition...