THE battle was an outright disaster; both sides agree. Muslim rebels defending territory around Mamasapano, in the Philippines’ southern island of Mindanao, killed dozens of intruding Filipino police on January 25th, after mistakenly thinking that they had come under attack.

The killings threaten to become a stumbling block to the peace process forged over the course of years between the government and the country’s biggest separatist outfit. They also demonstrate the need to execute swiftly an agreement the two sides signed last year. The terms of the agreement may fall short of bringing peace to Mindanao—the heartland of the Philippines’ Muslim minority, long a cauldron of secessionist and Islamist violence—but there is no better prospect in sight.

The government and its partner in peace, the Moro Islamic Liberation Front (MILF), a former adversary, agree that the fighting broke out when a force of paramilitary police encroached on MILF territory in Mamasapano in Mindanao. The police say they were after an Islamist terrorist they thought was being sheltered by another rebel group, the Bangsamoro Islamic Freedom Fighters (BIFF), which is not party to the peace agreement with the MILF. The police failed to co-ordinate their operation with either the army or the MILF—as the terms of the truce require. First the police came under fire from BIFF fighters. Then they manoeuvred onto MILF ground, where they then came under fire from MILF fighters, who thought the police were attacking them. The police found themselves outfought by BIFF and MILF rebels alike. When the shooting stopped at least 44 policemen were dead or dying, according to the government, as were five MILF fighters, according to the MILF. The casualty ratio suggests the police fell into an ambush.

The MILF and the government say the fighting between their forces was accidental. But the amount of bloodshed gave members of Congress pause. They are debating a bill regarding the constitution of a new autonomous Muslim region, which the MILF has accepted in lieu of independence. The administration of the president, Benigno Aquino, and the MILF alike have staked their reputations on this peace agreement; officials on each side urged Congress to press on. Their general fear is that failing to make good on the peace process would mean returning to secessionist combat, which has killed tens of thousands of people over a span of decades. The more particular fear is of something like what happened after the Philippines’ Supreme Court ruled that a peace deal struck by the previous administration was unconstitutional. In doing so, the court convinced some MILF rebels that the peace effort was hopeless—and that they should form the BIFF, and return to war. Even if Congress gets over the killings at Mamasapano, the constitutionality of the present peace agreement is debatable. The Supreme Court may be asked to pass judgment again.

Even if the agreement is upheld, peace may prove elusive. The circumstances of these killings indicate that some rebels and militant Islamists may fall through holes in the agreement. The one success the police were able to claim from their debacle is the possibility that the terrorist they were hunting was killed in the fight. He was—or is—a Malaysian, Zulkifli bin Hir, alias “Marwan”, allegedly a bomb-maker for the Jemaah Islamiah (JI) group. The United States had offered a reward of $5m for his capture.

Peace in Mindanao is not supposed to leave the place a haven for militant Islamists. The MILF denied any knowledge of Marwan’s presence—though its own territory abuts the BIFF’s, and until recently they were all one family. A self-policing autonomous region that turns a blind eye to BIFF and international terrorists would be unsustainable. And the MILF is not the only organisation that finds it difficult to keep its house in order. Mr Aquino said he had been aware of the operation to arrest Marwan and that he had issued a series of reminders about the need for co-ordination with the army—but the police made only minimal efforts to comply. After the massacre, the president sacked the commander of the paramilitary police. The disaster shows he was right to worry; independent action in the volatile atmosphere of Mindanao can be most unhelpful to the cause of peace.