That created an opportunity for Mr. Moon to back out of the agreement, but at the risk of upending South Korea’s relationship with Japan at a time when the countries are united in confronting North Korea over its weapons programs. The United States, the biggest ally of South Korea and Japan, had praised the 2015 agreement, saying cooperation between the two major Asian democracies was important for regional stability.

Under the “final and irreversible” settlement over the sex slaves, Japan was to make an apology in addition to providing the money for the survivors’ care. South Korea in turn pledged to not criticize Japan over the issue.

South Korea’s foreign minister, Kang Kyung-wha, said Tuesday that the 2015 agreement could not be considered “a genuine resolution” of the issue. But she added that there was no denying an official deal had been made and said Seoul wouldn’t push to renegotiate it. South Korea will set aside its own $8.8 million fund to care for the survivors, and continue discussions on what to do with the equivalent amount from Japan, Ms. Kang said.

Yoshihide Suga, Japan’s chief cabinet secretary, said Tuesday that Tokyo would ask Seoul to carry out the deal under its original terms. “There is no room for any compromise on that agreement,” he said.

The treatment of the women, known euphemistically as “comfort women,” is one of the most painful legacies of Japan’s occupation of Korea from 1910 to the end of World War II in 1945. Tens of thousands and possibly hundreds of thousands of women were compelled to work in brothels that served the Japanese military. In addition to Koreans, women from the Philippines, China and other countries invaded by Japan were forced into sexual slavery.