Thai and Cambodian troops have been camping at the temple for a month
Cambodia and Thailand have reached a deal to withdraw most of their troops from territory both claim at a hill-top temple, Cambodian officials say.
The agreement was reached at a meeting of military officers from the two countries on Wednesday.
Only a small contingent from each side would remain at Preah Vihear temple, a top general said.
More than 1,000 troops have been engaged in a stand-off at the ancient site for a month.
An international court awarded the temple to Cambodia in 1962, but land surrounding it remains the subject of rival territorial claims.
The decision by Unesco in June to list Preah Vihear as a World Heritage Site reignited lingering tensions over unresolved border disputes between the two countries.
The troop withdrawal would take place in the next few days, Cambodian General Neang Phat told journalists.
"Both sides agreed to redeploy the troops, who are stationed in the pagoda, to the lowest possible number in order to avoid confrontation with each other," he said.
Foreign ministers from the two countries will meet early next week for more talks, the general said.
The dispute erupted on 15 July. Thai troops moved into an area both sides claim after Cambodian guards arrested three Thai protesters there. Both sides then rapidly increased their military presence at the site.
Earlier this month, Cambodia accused Thailand of occupying a second border temple, Ta Moan.
The row was fuelled by domestic politics on both sides. Anti-government protest groups in Thailand exploited the issue to attack the ruling coalition, which had initially backed the Unesco listing.
The troop build-up also came just days before a general election in Cambodia - and the temple issue came to dominate the polls.
But tensions now appear to be easing somewhat, with both sides calling for dialogue.