Image copyright Reuters Image caption Mr Brokenshire said he requires lung surgery

Northern Ireland Secretary James Brokenshire has resigned from government, the Northern Ireland Office has confirmed.

It is understood he requires surgery for a lung condition.

Mr Brokenshire, 50, took the role in July 2016, replacing Theresa Villiers.

Prime Minister Theresa May, who is carrying out a cabinet reshuffle, paid a warm tribute to the outgoing secretary of state, and wished him a "speedy recovery".

Mr Brokenshire said recent health tests revealed that he has a "small lesion" in his right lung which needs to be removed.

He said his doctors believe he will be able to return to work after the operation, but it will take him "a number of weeks" to recover.

He added that it had been "a huge honour and privilege" to serve as secretary of state for Northern Ireland.

"My earnest wish for everyone in Northern Ireland is to see devolved government restored as quickly as possible."

His resignation comes almost a year to the day that the Northern Ireland Assembly collapsed following a scandal over a renewable energy scheme.

The coalition led by the Democratic Unionist Party (DUP) and Sinn Féin fell apart when the late Martin McGuinness resigned as deputy first minister on 9 January, 2017.

Despite months of negotiations aimed at restoring power-sharing, the parties have been unable to reach a deal to return to government.

In a letter to Mr Brokenshire, the prime minister wrote: "While it is typical of you that your first thought was not for yourself, but for your duties as a cabinet minister and public servant, it is absolutely right that you should put your health first, for your sake and that of your family."

DUP leader Arlene Foster said: "This is clearly a difficult time for not only James but for Cathy, his wife and his children. I send my best wishes to him and the entire Brokenshire family. I trust James will have the surgery he needs and will make a full recovery.

"Since becoming secretary of state in 2016, Mr Brokenshire had immersed himself fully in the role by dedicating long hours to trying to make progress.

"James leaves the role with a very intimate knowledge of Northern Ireland and I look forward to working with him again in the future."

Image caption Mr Brokenshire chaired months of negotiations aimed at restoring devolution

SDLP leader Colum Eastwood also sent his "sincere best wishes" to Mr Brokenshire.

"In the course of negotiations, the SDLP has often disagreed with the position of his government but I have always found Mr Brokenshire to be personable, reasonable and, so far as possible, helpful.

"Our thoughts are with him and his family as he takes time to concentrate on his health."

Labour Shadow Secretary of State, Owen Smith, tweeted his support, saying he was sure the people of Northern Ireland would "thank James for his diligent service".

Mr Brokenshire was first elected as the Conservative MP for Old Bexley & Sidcup in May 2010. He was subsequently re-elected in 2015 and again in 2017 with more than 60% of the vote.

He lives in Bexley with his wife, Catherine, and the couple's three children.

Before entering parliament, Mr Brokenshire was a partner in an international law firm.

From May 2011 to May 2015, he served as security minister at the Home Office.

That role included supporting Mrs May, the then home secretary, with oversight of the work of MI5 and the national police counter-terrorism network.

BBC News NI political correspondent Gareth Gordon

As far as Theresa May was concerned, at a time of unprecedented upheaval, James Brokenshire was probably as near to a being a safe pair of hands as her current Cabinet possessed.

But in Northern Ireland, as devolution collapsed around him, he was often dismissed as a "do-nothing" secretary of state who allowed the situation to drift when decisive action was required.

For republicans and nationalists, he and his government were seen as being too close to the DUP.

As far as some in the DUP were concerned, he should have already moved towards introducing direct rule in the face of what they saw as Sinn Fein intransigence.

Caught between these two positions, he appeared to be impotent, but whoever replaces him will face exactly the same problems.

His responsibilities also included the government's counter-terrorism strategy and he was part of the prime minister's extremism taskforce.

He also led negotiations with the Jordanian government to secure the deportation of the radical cleric Abu Qatada.