Thailand and Cambodia agreed Monday to an unconditional cease-fire after five days of border fighting that left at least 36 people dead.

Nearly 300,000 people have fled as the two sides fired artillery, rockets and guns in a battle over the long-disputed area, which is home to a smattering of ancient temples.

The flare-up was the deadliest since violence raged sporadically from 2008-2011 over the territory, claimed by both sides because of a vague demarcation made by Cambodia's French colonial administrators in 1907.

Reading a joint statement from the leaders of both countries after peace talks, Malaysian Prime Minister Anwar Ibrahim said they had agreed "an immediate and unconditional cease-fire" with effect from midnight Monday (5 p.m. GMT).

"This is a vital first step towards de-escalation and the restoration of peace and security," he said at a press conference in Malaysia's administrative capital, Putrajaya, flanked by Thai acting Prime Minister Phumtham Wechayachai and Cambodia's Prime Minister Hun Manet.