Japan and South Korea said Monday that they had “finally and irreversibly” resolved a dispute over wartime sex slaves that has bedeviled relations between the two countries for decades.

In something of a surprise development, the two countries’ foreign ministers met in Seoul to finalize a deal that will see Japan put $8.3 million into a South Korean fund to support the 46 surviving “comfort women” and to help them recover their “honor and dignity” and heal their “psychological wounds.”

The move was welcomed in Washington, which has been both concerned and annoyed by the tensions between its two closest allies in Asia. This year marks seven decades since the end of World War II and the end of Japan’s occupation of the Korean Peninsula.

Independent historians have concluded that as many as 200,000 women and girls — from occupied countries including Korea, China, the Philippines and other Southeast Asian nations — were coerced by the Japanese Imperial Army to work as sex slaves during the war.

“We made a final and irreversible solution at this 70th anniversary milestone,” Japanese Prime Minister Shinzo Abe told reporters in Tokyo after speaking to his South Korean counterpart, President Park Geun-hye, on the phone.

South Korean bereaved family members of victims of World War II stage a rally in Seoul, South Korea, on Dec. 28, 2015. (Ahn Young-joon/Associated Press)

Earlier, in Seoul, his foreign minister had said Abe “expresses anew his most sincere apologies and remorse to all the women who underwent immeasurable and painful experiences.”

“I feel we’ve fulfilled the responsibility of the generation living now,” Abe said after his call with Park. “I’d like this to be a trigger for Japan and South Korea to cooperate and open a new era.”

In Seoul, Park said it was “especially meaningful” to reach the agreement before the end of 2015, the 50th anniversary of normalized relations between the two countries.

“The most important thing is for Japan to diligently and promptly implement what has been agreed to restore comfort women victims’ honor and dignity and heal their wounded hearts,” Park said, according to the Yonhap News Agency, after meeting with Fumio Kishida, Japan’s foreign minister.

Japanese officials do not consider the $8.3 million payment to be compensation. It is based on the amount paid into the Asian women’s fund in 1995, set up to give private donations to each victim, worth about $45,000 each at the time. It is to be used to provide medical care and other services to the survivors.

The bigger issue now, South Korean officials say, is whether Japan can secure the money for this deal, because the fund will come from the government’s coffers. There is some concern that conservative politicians opposed to the agreement will try to block the budget allocation.

Some of the 46 surviving women rejected the agreement because it did not resolve outstanding legal claims.

A South Korean bereaved family member of victims of World War II attends a rally demanding full compensation and an apology from the Japanese government in front of Foreign Ministry in Seoul, South Korea on Dec. 28, 2015. (Ahn Young-joon/Associated Press)

Lee Yong-su, an 88-year-old former comfort woman, said she would “ignore it all.”

“I don’t think comfort women victims were even considered” in the resolution, she told reporters after the deal, adding that Japan has not taken legal responsibility for the comfort women issue.

Seoul nonetheless promised that this would end the dispute — which has been officially “resolved” before — as long as Japan fulfills its side of the deal. It comes less than two months after the two leaders held their first summit and after the resolution of a high-profile court case, with a Japanese journalist this month acquitted of defaming Park.

Notably, both sides agreed to stop “accusing or criticizing each other regarding this issue in the international community, including at the United Nations.” Some of that has played out in the United States, with South Koreans erecting memorials to comfort women and Japan trying to have references to “forcible recruitment” removed from U.S. college textbooks.

In Washington, Secretary of State John F. Kerry hailed the agreement, saying it took “courage and vision” to settle the issue.

“We believe this agreement will promote healing and help to improve relations between two of the United States’ most important allies,” he said in a statement Monday afternoon.

A senior State Department official, speaking on the condition of anonymity under State Department ground rules for briefing reporters, likened the agreement’s strategic importance to the ­Trans-Pacific Partnership, a sweeping trade pact joining 12 Pacific Rim nations. It will contribute to “a more stable, secure and prosperous Asia,” the official said.

Tokyo had considered the dispute formally resolved in 1965, when it normalized relations with South Korea and offered $800 million in compensation for all aspects of its colonial-era brutality.

Japan officially apologized in 1993, after a government study that led Yohei Kono, then the chief cabinet secretary, to offer Japan’s “sincere apologies and remorse to all those . . . who suffered immeasurable pain and incurable physical and psychological wounds as comfort women.”

But the issue has remained emotionally charged, with many South Koreans in recent years seizing upon statements by Abe’s associates and other conservatives that the women were prostitutes. Park and other politicians have repeatedly called on Abe to atone properly.

Tomiichi Murayama, who was the first Japanese prime minister to officially apologize and helped establish a fund for the women, said the deal was encouraging.

“Now that this bottleneck comfort women issue is solved, I hope Japanese and South Korean relations will progress positively,” he told public broadcaster NHK.

Some analysts questioned whether the deal can hold, given the strength of opposition on both sides.

Barely an hour after the agreement was announced, Akie Abe, the Japanese prime minister’s wife, made a visit to the Yasukuni shrine in Tokyo. The site is controversial for Koreans and Chinese because included in the 2.5 million Japanese war dead memorialized there are 14 people convicted of Class A war crimes.

“Heisei 27, the year when we marked the 70th anniversary of the end of the war,” Akie Abe wrote in a post on Facebook, referring to the Japanese calendar year. “We only have few [days] remaining. The last visit of the year,” she wrote, above two photos of the shrine at dusk.

Although it is common for Japanese to visit shrines on the last day of the year, some analysts doubted the timing of Abe’s early visit was coincidental.

There is also another sticking point: a bronze statue of a girl, symbolizing a “comfort woman,” outside the Japanese Embassy in Seoul. Japan has been asking for the statue to be removed, and South Korea has agreed to explore the possibility of moving it.

In a post on its Facebook page, a South Korean group called Justice to the Comfort Women noted that Abe did not make an apology himself but had his foreign minister read it, and described it as ambiguous. “Therefore, it is impossible to accept today’s apology as a sincere one,” the post said. The group also chastised the government, saying it was “humiliating and disappointing” that Park’s administration would try to move the statue and refrain from criticizing Japan.

Yoongjung Seo in Seoul, Yuki Oda in Tokyo, and Juliet Eilperin and Carol Morello in Washington contributed to this report.