A ceasefire between Thailand and Cambodia has come into effect along the border, where almost three weeks of deadly clashes have forced nearly one million people from their homes.

In a joint statement, the defence ministers of the two countries agreed to freeze the front lines where they are now, ban reinforcements and allow civilians living in border areas to return as soon as possible.

The ceasefire took effect at noon local time (05:00 GMT) on Saturday. Once it has been in place for 72 hours, 18 Cambodian soldiers held by Thailand since July will be released, the statement said.

The breakthrough came after days of talks between the two countries, with diplomatic encouragement from China and the US.

The agreement prioritises getting the displaced back to their homes, and also includes an agreement to remove landmines.

Thailand's Defence Minister Natthaphon Narkphanit described the ceasefire as a test for the other party's sincerity.

Should the ceasefire fail to materialise or be violated, Thailand retains its legitimate right to self-defence under international law, he told reporters.

UN human rights chief Volker Türk expressed hopes that the ceasefire would pave the way for peace, while an EU spokesperson urged good faith in its implementation.

Thailand had been reluctant to accept the ceasefire, citing failures in previous agreements. Unlike the last ceasefire in July, US President Donald Trump was absent from this one, although the US State Department was involved.

The Thai army claimed it had responded to Cambodian fire, while Cambodia insisted they did not retaliate during previous conflicts. Clashes continued throughout December, raising concerns over the future of this latest ceasefire.

Disagreement over the border territories dates back over a century, but tensions escalated earlier this year, leading to tragic losses on both sides and making peace efforts more complicated.

Cambodia has faced significant military setbacks and casualties, while nationalist sentiments in both countries could fuel further conflict if not managed carefully.