Media playback is unsupported on your device Media caption Sinn Féin says election is "watershed" moment which ended Stormont's unionist majority

Sinn Féin has hailed the assembly election as a "watershed" moment after the party came within one seat of drawing level with the DUP.

Only 1,168 first preference votes separated the two parties and, for the first time, unionists do not have an overall majority at Stormont.

Sinn Féin President Gerry Adams said: "The notion of a perpetual unionist majority has been demolished."

Its northern leader Michelle O'Neill is to lead talks to restore power-sharing.

She said: "The task is not easy, but it is achievable if people come at it with the right attitude."

Amid the fallout, Mike Nesbitt said he would resign as Ulster Unionist leader.

The election was called after the collapse of a coalition led by Arlene Foster's DUP and Sinn Féin's Martin McGuinness.

Sinn Féin and the DUP now have three weeks to establish a government: Under Northern Ireland's power-sharing agreement, the government must be run by Irish nationalists and unionists together.

If a government cannot be formed within that time then, under law, another election will be called.

Image copyright Getty Images Image caption DUP leader Arlene Foster said she was pleased the DUP remained the largest party, despite its seat losses

Mrs Foster said she was pleased the DUP won the most votes, adding: "I do hope devolution will get back up and running as quickly as possible."

The DUP's Jeffrey Donaldson said it would be unfair to focus on "just one individual" when asked about the party's loss of seats and Mrs Foster's future as its leader.

The party would have to "listen to the concerns expressed during the election", but was focused on forming a government, he added.

'Clear desire'

Ultimately, if no power-sharing government is formed, devolved power could return to the UK parliament at Westminster for the first time in a decade.

Secretary of State James Brokenshire said the election had demonstrated the desire by the overwhelming majority of voters for inclusive, devolved government.

"Everyone now has a shared responsibility to engage intensively in the short period of time that is available to us, to ensure that a strong and stable administration is established," he said.

Media playback is unsupported on your device Media caption BBC News NI looks at the next steps for the Stormont Assembly

David Trimble, a former Ulster Unionist Party leader who also served as first minister of Northern Ireland, suggested the parties would need more time to reach an agreement.

"If there isn't an administration put in place then the Secretary of State for Northern Ireland is on a legal obligation to dissolve the assembly and have another general election, which I doubt will get us anywhere."

High-profile casualties

A total of 64.8% of the electorate voted in the second Assembly election in 10 months - the highest turnout since the vote which followed the 1998 Good Friday Agreement and up 10 points on last May's vote.

The result means the DUP no longer has enough MLAs - 30 - to deploy Stormont's controversial petition of concern without the support of others.

The petition can be used as an effective veto and had been used by the DUP to block motions including a move to lift the ban on same-sex marriage.

The election saw Mrs Foster, Mrs O'Neill, Alliance Party leader Naomi Long and SDLP leader Colum Eastwood among those elected.

Mike Nesbitt won his seat at the Strangford count but shortly afterwards, he announced that he was to stand down as Ulster Unionist leader following his party's poor performance.

Indicating that he will remain in position until his successor is found, he said his real regret was that Northern Ireland's society appeared to have emerged from the election more polarised.

"Some day Northern Ireland will vote as a normal democracy," he said. "We will vote in a post-sectarian election, but it's now clear it will not happen during the duration of my political career."

SDLP leader Colum Eastwood said the return of 12 MLAs to a reduced Assembly was a statement of intent as the party had arrested a period of decline.

"This is the first time since 1998 that we have recorded gains. The SDLP is on the move," he added.

Media playback is unsupported on your device Media caption Nelson McCausland one of the poll's several high-profile casualties

He also paid tribute to the "bravery and the humility" shown by Mr Nesbitt during the campaign.

While Mr Nesbitt held his Assembly seat, other high-profile MLAs were not so lucky.

The SDLP's Alex Attwood, the UUP's Danny Kennedy, and the DUP's Nelson McCausland and Lord Morrow were former executive ministers who failed to secure a return to a Stormont legislature that is being cut from 108 to 90 members.

Other casualties included the UUP's Jo-Anne Dobson, former DUP minister Jonathan Bell, who stood as an independent, and People Before Profit's Eamon McCann, who was elected as an MLA last May but lost his seat in Foyle.

Mr McGuinness resigned over Mrs Foster's refusal to step aside as first minister pending an inquiry into the Renewable Heat Incentive (RHI) scheme, which could cost the Northern Ireland tax payer £490m.

A total of 1,254,709 people were eligible to vote for 228 candidates competing for 90 seats in 18 constituencies.

Image copyright Pacemaker Image caption Martin McGuinness resigned over Mrs Foster's refusal to step aside as first minister pending an inquiry into a botched energy scheme

The BBC News NI website will carry all the latest on the election throughout the weekend.

There are also special election programmes running on BBC Radio Ulster from 09:00 GMT .