An recent upsurge in violence on Mindanao has left hundreds dead
Muslim rebels and the army have fought an eight-hour battle in the southern Philippines, leaving 20 insurgents and seven soldiers dead, the military says.
Lt Col Jonathan Ponce said the army attacked rebels from the Moro Islamic Liberation Front (MILF) to stop them from ransacking nearby villages.
The MILF blamed the army for the battle, on Mindanao island.
Hundreds have died and many thousands have been displaced on Mindanao since August, when peace talks foundered.
The MILF, the largest of the country's numerous separatist groups, has been fighting for an independent homeland for decades.
Lt Col Ponce described a long and bloody battle with a group of 80 rebels in Maguindanao province.
"Some bodies were hanging on treetops. They got hit by our artillery shelling. But we lost seven men and five were also wounded," he said.
"Based on our intelligence, this group was planning to attack villages, so we pre-empted them."
He said troops were still pursuing groups of fleeing rebels.
MILF spokesman Eid Kabalu disputed how many people had died in the clashes, and accused the military of "playing games".
"This attack only proves they want to create confusion on the ground at a time when government is trying to restart the talks," he told the AFP news agency.
The battle came as President Gloria Arroyo was visiting the province and was just a few miles away from the violence.
The government and MILF negotiators framed a deal last year which would have expanded an autonomous Muslim region on Mindanao.
But parliament blocked the agreement, saying the government had not adequately consulted Christian communities in Mindanao - who form a majority on the island.
After the deal collapsed, groups of disaffected MILF guerrillas rampaged through Christian villages, killing civilians and burning houses and land.
The military responded and the ensuing fighting has displaced hundreds of thousands and put the region on the brink of a humanitarian disaster.
Although the government is keen to restart peace talks, no date has been set.