A senior Japanese official paid his respects at a controversial shrine for war dead on Wednesday, potentially marring Prime Minister Shinzo Abe's earlier groundbreaking visit to Pearl Harbor with President Barack Obama.

The visit by Masahiro Imamura, Abe's cabinet minister for reconstruction, to Tokyo's Yasukuni Shrine for war dead — seen by China and South Korea as a symbol of Japan's past militarism — prompted a sharp rebuke from Beijing.

South Korean college students march with portraits of deceased former South Korean sex slaves who were forced to serve for the Japanese military in World War II during a rally against Japanese government in Seoul, South Korea, on Wednesday. Kim Ju-sung / AP

"China is firmly against any visit by Japanese cabinet members to the Yasukuni Shrine which worships class-A criminals in the Second World War," Foreign Ministry's spokeswoman Hua Chunying said, referring to the regular visits to the shrine by a small group of officials.

She added in a statement: "We once again urge the Japanese side to look squarely at and deeply reflect upon the past history of aggression, take a responsible attitude to properly handle relevant issues, and make tangible moves to win the trust of its Asian neighbors and the world."

Abe's visit 75 years after the attack on Pearl Harbor and his attendance at the USS Arizona Memorial marked the first such trip in decades by a Japanese prime minster. During the Japanese attack on Pearl Harbor, 2,403 Americans were killed on Dec. 7, 1941.

Visitors pray at the Yasukuni Shrine, which honours millions of Japanese war dead but also senior military and political figures convicted of war crimes after World War II, in Tokyo on Wednesday. KAZUHIRO NOGI / AFP - Getty Images

Some Abe critics noted the Japanese leader's visit, and the reconciliation with the United States that it symbolized, underscored the stark contrast in its relationship with China and South Korea.

Anger toward Japan runs deep in both countries, where many feel that Japan has not fully atoned for their brutal behavior during World War II. Especially sensitive in China is the sack of Nanking, where hundreds of thousands of Chinese are believed to have been killed and raped during the Japanese army's vicious 1937 attack.

Related: Japan, South Korea Reach Historic Deal on Wartime 'Comfort Women'

In South Korea, which Japan occupied for much for the first half of the 20th Century, the plight of so-called comfort woman — essentially sex slaves serving Japanese soldiers — is still a live issue that causes grief and anger.

Abe himself upset Beijing, Seoul and Washington with his own visit to Tokyo's Yasukuni Shrine shrine three years ago this month.

"A symbolic gesture of contrition to your closest ally is easy," Jeffrey Kingston, director of Asian studies at Temple University's Japan campus in Tokyo, told Reuters."If [Abe] really is sincere about reconciliation diplomacy and overcoming lingering enmities he needs to visit similar symbolic sights (in China and Korea) ... and make similar remarks of remorse that are more specific about Japan's responsibility."