THE return to power-sharing in Northern Ireland appeared a distant prospect last night.

London and Dublin's worst case scenario materialised at the polls when Ian Paisley's Democratic Unionists (DUP) emerged as the largest party.

The result means that there is now a unionist majority opposed to the Good Friday Agreement and it put in doubt the future of David Trimble as leader of the divided Ulster Unionist party (UUP).

As support for the moderate nationalist SDLP crumbled, Sinn Fein (SF) took over as the majority party of nationalism in the province.

Late last night with all 108 seats allocated, the DUP had 30 (up 9), SF had 24 (up 6), the UUP 27 (down 1) and the SDLP 18 (down 6).

The DUP gained seats largely at the expense of the minor unionist parties. Turnout out was 64%, down five points.

London and Dublin sought to put a brave face on what was a desperately disappointing result for them.

In a joint statement Tony Blair and Bertie Ahern, his Irish counterpart, said they would contact parties over the coming days to ''seek a political way forward and to secure a basis on which the assembly can be restored and a functioning executive quickly established''. However, they also made clear the agreement remained ''the only viable political framework'' in Northern Ireland and insisted it was not ''open to negotiation''.

They accepted, with most votes in, the people of Northern Ireland had spoken and said they would work with the parties. However, they emphasised that with success ''comes responsibility'' and pointed out that for devolution to succeed it had to be stable and fully inclusive.

The Good Friday Agreement was, they argued, the only viable way forward, stressing: ''We are determined that its wide-ranging provisions will continue to be implemented.'' Paul Murphy, the secretary of state, is expected to begin talks with the main parties today.

London and Dublin said in the coming days they would ask parties to submit their views about how the review of the agreement should be conducted and what its agenda should be.

Mr Blair and Mr Ahern are expected to meet before Christmas and last night they said they hoped to finalise and present proposals for the review early in the new year after receiving responses from the parties.

They added: ''This is a review of the operation of the agreement. Its fundamentals are not open to renegotiation.''

However, this is not how Dr Paisley sees it. The North Antrim MP said: ''The agreement has been over for a long time . . . We have to go back to the drawing board.''

As for the possibility of him or his colleagues sharing power with SF's Gerry Adams or Martin McGuinness, the 77-year-old firebrand said: ''As a principle, I do not work with murderers,'' claiming it would be a ''crime against all those men who fought and died to say that we must be forced to sit down with the killers of their kith and kin and give them a place in government''.

As for his UUP counterpart, Dr Paisley was equally ungenerous. ''He's yesterday's man, the party will get rid of him. He is a nobody, a nothing. He's done great damage.''

For his part, Mr Trimble said the DUP had ''sold the people a false bill of goods,'' suggesting another agreement existed that would not have ''any of the awkward bits in it''. He added: ''The DUP can't deliver and that will become clear and it will become clear very quickly.''

However, Mr Trimble's leadership is now under a great deal of pressure. While he said he had every intention of continuing as leader, having ''demonstrated over the last eight years there's more than a little stickability here,'' on Monday he will face his detractors at a meeting of the new UUP Assembly group.

His main critic, Jeffrey Donaldson, the anti-agreement hardliner, warned: ''It is time for change and if a vacancy arises, I will consider putting my name forward. This party is not going to unite under David Trimble.''

Mr Trimble urged his internal critics not to get carried away.

''They should not let their ambition cloud their judgment on this matter,'' he said. ''We are in a position where we have actually increased our share of the vote.''

Mr Adams, the SF president, declaring it had been a good election for his party, appeared philosophical about the result on the unionist side. He said: ''There is a crisis within unionism that will need some patience for the rest of us to show in the time ahead.''