The leaders of Japan and South Korea have welcomed the agreement between their two countries to settle the issue of "comfort women" forced to work in Japanese brothels during World War Two.
Japan has apologised and will pay 1bn yen ($8.3m; £5.6m) - the amount South Korea asked for - to fund victims.
Estimates suggest up to 200,000 women were sex slaves for Japanese soldiers during WW2, many of them Korean.
Other women came from China, the Philippines, Indonesia and Taiwan.
The issue has been the key cause of strained relations between Japan and South Korea.
Only 46 former "comfort women" are still alive in South Korea.
The agreement came after Japan's Foreign Minister Fumio Kishida met his counterpart Yun Byung-se in Seoul, following moves to speed up talks.
Later Japanese Prime Minister Shinzo Abe phoned South Korean President Park Geun-hye to repeat an apology already offered by Mr Kishida.
"Japan and South Korea are now entering a new era," Mr Abe told reporters afterwards. "We should not drag this problem into the next generation."
Ms Park issued a separate statement, saying a deal had been urgently needed - given the advanced age of most of the victims.
"Nine died this year alone," she said. "I hope the mental pains of the elderly comfort women will be eased."
Japan-South Korea 'comfort women' deal
- Japan will give 1bn yen to a fund for the elderly comfort women, which the South Korean government will administer
- The money also comes with an apology by Japan's prime minister and the acceptance of "deep responsibility" for the issue
- South Korea says it will consider the matter resolved "finally and irreversibly" if Japan fulfils its promises
- South Korea will also look into removing a statue symbolising comfort women, which activists erected outside the Japanese embassy in Seoul in 2011
- Both sides have agreed to refrain from criticising each other on this issue in the international community
Read more: 'Comfort women' - a painful legacy
After the meeting in Seoul, Mr Kishida called the agreement "epoch-making".
"Prime Minister Abe expresses anew his most sincere apologies and remorse to all the women who underwent immeasurable and painful experiences and suffered incurable physical and psychological wounds as comfort women," Mr Kishida told reporters.
The wording of the deal does not explicitly state that the "comfort women" will receive direct compensation, but states that the fund will provide "support" and bankroll "projects for recovering the honour and dignity and healing the psychological wounds".
Some former "comfort women", such as Lee Yong-soo, have taken issue with this.
The 88-year-old told the BBC: "I wonder whether the talks took place with the victims really in mind. We're not after the money. If the Japanese committed their sins, they should offer direct official government compensation."
Another former "comfort woman", 88-year-old Yoo Hee-nam, said: "If I look back, we've lived a life deprived of our basic rights as human beings. So I can't be fully satisfied.
"But we've been waiting all this time for the South Korean government to resolve the issue legally. As the government worked hard to settle deal before the turn of the year, I'd like to follow the government's lead."
In Japan journalist Nobuo Ikeda reflected the view of many on Twitter that the country had lost out, although others thought the deal could have been worse for Mr Abe.
"Japan pays 1bn yen and our PM apologises but South Korea will 'consult about the girl's statue' - that's not a diplomatic negotiation," Mr Ikeda tweeted.
Kevin Kim, BBC News, Seoul
With only days left until the end of the year, the timing of the talks was highly symbolic and the expectations for results were high.
Earlier in the year, the South Korean president called for a resolution to the "comfort women" dispute by the year's end, marking the 50th anniversary of diplomatic relations.
However, few believed that a quick breakthrough could be reached on a thorny issue that has strained the region for decades and some critics say the talks have been rushed to preserve the symbolism.
It's unclear if Japan's admission of responsibility was legal or just humanitarian, and Tokyo's offer of 1bn yen has been described as a measure to help the women, not as direct government compensation.
The dozens of surviving women have asked for a formal apology specifically addressed to themselves, and direct compensation. They say past expressions of regret have been only halfway and insincere.
Negotiators appear to have overcome several obstacles including disagreements over the wording of the agreement and the amount of compensation. Tokyo was reportedly initially considering paying only about 100m yen.
The United States congratulated the governments of Japan and South Korea on reaching the agreement.
"We believe this comprehensive resolution is an important gesture of healing and reconciliation," a White House statement said.
"The United States applauds... two of our most important allies for having the courage and vision to forge a lasting settlement to this difficult issue."
Japan has repeatedly apologised or acknowledged its responsibility for wartime sex slaves, most notably in a 1993 statement by the then-chief cabinet secretary Yohei Kono.
It had also resisted giving greater compensation, arguing that the dispute was settled in 1965 when diplomatic ties were normalised between the two countries and more than $800m in economic aid and loans was given to South Korea.
A private fund was also set up in 1995 for the victims and lasted for a decade, but money came from donations and not from the Japanese government.