TOKYO—Former Japanese Prime Minister Shinzo Abe on Saturday visited a Tokyo shrine linked to Japan’s militarist past, waiting only three days after his departure from office to resume a longstanding practice that had angered Asian neighbors.

Mr. Abe visited the Yasukuni Shrine on Dec. 26, 2013, a year after taking office, prompting a rare rift with the U.S. At the time, the U.S. Embassy in Tokyo said it was disappointed that Mr. Abe had “taken an action that will exacerbate tensions with Japan’s neighbors.”

Abe supporters said he wanted to go again while in office but refrained out of consideration for U.S.-Japan relations.

On Saturday, Mr. Abe tweeted a picture of himself visiting the shrine in central Tokyo, walking behind a Shinto priest. “Today I paid my respects at Yasukuni Shrine and reported to the spirits of fallen heroes that I departed the office of prime minister,” Mr. Abe wrote.

Mr. Abe announced his resignation on Aug. 28 and formally resigned on Sept. 16. He was replaced the same day by Yoshihide Suga, his former chief aide. Mr. Suga said in 2014 that he had visited Yasukuni before becoming a cabinet minister in Mr. Abe’s government, but he didn’t do so as a minister and isn’t associated with the nationalist camp of lawmakers in the ruling Liberal Democratic Party that advocates visits to Yasukuni.

South Korea’s Ministry of Foreign Affairs released a statement expressing “deep concern and regret” over Mr. Abe’s visit to what it called “a symbolic establishment that glorifies Japan’s colonial invasion and war aggression.” Japan colonized the Korean peninsula from 1910 to 1945. The ministry said leaders of Japan wouldn’t earn neighbors’ trust unless they “correctly confront its history.”

Visits to Yasukuni by Japanese prime ministers typically spark protests by South Korea and China. After Mr. Abe’s 2013 visit, South Korea said it was a “final blow to ongoing efforts to improve relations between South Korea and Japan.” The rest of Mr. Abe’s tenure in office was marked by frequent clashes with Seoul.

Yasukuni is a shrine to war dead that dates to 1869. It honors 2.5 million Japanese killed since the late 19th century. In 1978, 14 men who were designated as Class A war criminals in tribunals after World War II were added to those enshrined there. Among them is Gen. Hideki Tojo, a Japanese prime minister during the war.

Write to Peter Landers at peter.landers@wsj.com