TOKYO — Justin Bieber apologized Wednesday to those he offended by visiting a Japanese war shrine, saying he thought it was a beautiful site and only a place of prayer.

The Yasukuni Shrine in central Tokyo enshrines 2.5 million war dead, including Japan’s 14 convicted war criminals, and operates a war museum that defends Japan’s wartime aggression. It is a flash point between Japan and its neighbors that see the shrine as distinct from other Shinto-style establishments mainly honoring gods of nature. China and South Korea in particular see Yasukuni as a symbol of Japan’s past militarism and consider Japanese officials’ visits there as a lack of understanding or remorse over wartime history.

Two images posted on Bieber’s Instagram account were met with outrage from Chinese officials and by commenters on social media. Chinese Foreign Ministry spokesman Qin Gang said the pop star should remember China’s position on Yasukuni.

“I hope this Canadian singer, after his visit, can have some knowledge of the Japanese militaristic history of external aggression and their militaristic thinking,” he said.

Yasukuni confirmed Bieber visited earlier this week.