Media playback is unsupported on your device Media caption Mary Lou McDonald succeeds Gerry Adams as Sinn Féin leader

Mary Lou McDonald has been formally elected as leader of Sinn Féin, replacing Gerry Adams who led the party for almost 35 years.

Mr Adams, 69, announced his intention to quit the role in November in a move that signalled a generational shift in the Sinn Féin leadership.

Ms McDonald, 48, said she was "humbled" to lead "Ireland's oldest and greatest political party".

Michelle O'Neill, 41, has also been installed as Sinn Féin vice president.

The elections took place at a special ard fhéis (party conference) in Dublin.

Image copyright Press Eye Image caption Mary Lou McDonald and Michelle O'Neill at their party conference in Dublin

Ms McDonald paid tribute to Mr Adams, saying there would have been no peace process and no Good Friday Agreement without him.

She described him as her political mentor, an "inspirational" leader and a "great friend".

In her first speech as leader, she warned that Brexit represents a real threat to the prosperity and political life of Ireland.

"There can be no imposition of a border on the island of Ireland, that message must go loud and clear from our ard fhéis today. Ireland will not be the collateral damage in the political games and antics of the Tories in London."

Image copyright AFP/Getty Image caption Mary Lou McDonald described Gerry Adams as her mentor and friend

Turning to the talks at Stormont, she pledged that her party was up for a deal.

"The Sinn Féin team is committed to a positive outcome. As Uachtarán Shinn Féin (Sinn Féin leader) I look forward to working with the DUP and with the other parties in the north."

Michelle O'Neill told the ard fhéis that she expected the talks to restore devolution at Stormont to conclude next week.

"I believe that the issues which caused the collapse of Stormont can be resolved with political will and mutual respect," she said.

"Issues like marriage equality, an Irish language act, legacy inquests, rights, respect and integrity in government should not be politically contentious.

Image copyright Press Eye Image caption Michelle O'Neill and Mary Lou McDonald at the ard fhéis in Dublin

"A restored executive with genuine power-sharing at its heart and acting in the interests of all people."

Mrs O'Neill said it was vital to heal the pain of the past.

"Part of reconciliation involves recognising everyone's right to remember their dead," she said.

"But what's required is a unionist partner to help lead this crucial effort together."

Image copyright Kelvin Boyes / Press Eye Image caption Gerry Adams pictured in the audience at the ard fhéis

Mrs O'Neill called for a referendum on a united Ireland.

"We must face outwards and listen to those who don't want a united Ireland," she said.

"It is our task to persuade those people, sectors and communities of why it's in their best economic and political interests to share power across this island."

Saturday's elections were a formality as both women ran unopposed for the leadership roles.

Mr Adams is one of the most prominent and controversial Irish politicians and his political legacy will divide opinion sharply.

Media playback is unsupported on your device Media caption Gerry Adams: In his own words

Speaking on Friday night, he said he was "confident" that the new leadership would "help make Sinn Féin even bigger and stronger in the time ahead".

"Fifty years ago when I joined Sinn Féin, it was a banned party," he said.

Image copyright Reuters Image caption Gerry Adams with Michelle O'Neill and Mary Lou McDonald

"The nationalist people of the north had been abandoned and were subject to discrimination and inequality. We were on our knees. We are now off our knees.

"We have a Good Friday Agreement. It is in some difficulty at this time. But it offers the way forward."

The leadership change comes almost 20 years after the 1998 Good Friday Agreement, but it also comes at a time of great political uncertainty.

Northern Ireland has been without a devolved government since Martin McGuiness quit as deputy first minister in January 2017, in a move which caused the assembly to collapse.

Image copyright Reuters Image caption Gerry Adams pictured leaving Stormont on his last night as leader of Sinn Féin

He pulled Sinn Féin out of its power-sharing coalition with the Democratic Unionist Party (DUP), objecting to their handling of a scandal over green energy scheme.

Several rounds of talks aimed at restoring devolution have failed, but there is now growing speculation that a deal could be unveiled as early as next week.

Ms McDonald and Mrs O'Neill have been present all week at talks in Stormont which have been described as a last ditch attempt to restore power-sharing.

Mrs O'Neill has been the party's leader north of the Irish border for just over a year, having taken over from the late Martin McGuiness in January 2017.

Image copyright Reuters Image caption Mary Lou McDonald (left) and Michelle O'Neill ran unopposed for their new roles

Sinn Féin sources have said that the talks are at a crucial stage.

They are taking place against the complicated backdrop of Brexit and the way it impinges on economic and political matters, both in Anglo-Irish relations and in cross-border co-operation.

As Mr Adams left the Stormont talks on Friday night - for the last time as Sinn Féin leader - he said: "It isn't sorted out as we speak.

"We have made some progress but there are still considerable obstacles. But, as I said to our unionist friends, this is the last chance agreement."