Foes in a bloody conflict over independence for New Caledonia agreed Saturday on the final shape of a pact that would divide the Pacific islands until a 1998 referendum on nationhood.

Melanesian separatists and loyalists to French rule hammered out the final document at dawn after marathon negotiations on about 120 articles ended with a compromise on amnesty for militant nationalists.The agreement was regarded as a political triumph for Socialist Prime Minister Michel Rocard, who launched the Caledonian peace initiative and brokered negotiations for a draft accord in June.

Early May saw the end of a bloody uprising by Melanesian separatists, or Kanaks in local parlance. The violence, which claimed 30 lives, was triggered by local elections in the South Pacific territory.

The settlement divides New Caledonia into three regions to be administered by their mainly Melanesian islander and European settler majorities. A local referendum on nationhood is to be held in 1998.

The French government has promised $47 million in economic assistance, an addition to the normal subsidies received by the territory to reduce disparities between former warring camps.