Jennie Formby, a close ally of Jeremy Corbyn, has stood down as Labour’s general secretary, saying it is the “right time” to resign while Sir Keir Starmer reshapes the party.

She said on Monday that her two years in the role had been a “huge privilege” and wished Sir Keir the “very best of luck” in leading Labour into the next general election.

Her time as general secretary saw the party rocked by anti-Semitism claims and rows over Mr Corbyn’s leadership.

“When I applied for the role of general secretary in 2018 it was because I wanted to support Jeremy Corbyn, who inspired so many people to get involved in politics with his message of hope, equality and peace,” she said in a statement.

“It has been a huge privilege to be general secretary of the largest political party in Europe for the last two years, but now we have a new leadership team it is the right time to step down.

“I would like to thank Jeremy, our members and my staff colleagues who have given me so much support during what has been a very challenging period, in particular when I was suffering from ill health.”

Ms Formby underwent chemotherapy for cancer during her time as general secretary.

Sir Keir thanked her for “the personal and professional efforts she has made in advancing the cause she has fought all her life for”.

“Jennie has led our party’s organisation with commitment and energy through a period of political upheaval, including a snap general election last year. I wish her the very best for the future,” he added.

The resignation comes as Labour investigates the leaking of a controversial dossier on anti-Semitism, which blamed “factional opposition” towards Mr Corbyn and hindered efforts to tackle the crisis.

Labour has been forced to defend its data protection handling and work with the Information Commissioner’s Office over the leak, with legal challenges threatened by those named in the report.

Her departure will help Sir Keir in restructuring the Labour Party, with the new general secretary being chosen by Labour’s ruling National Executive Committee, which he sits on as leader.

It remains to be seen whether Karie Murphy, another key Corbyn ally, will make way for the overhaul of the party’s leadership.

Mr Corbyn paid tribute to Ms Formby as a “great friend and comrade” and said he looks forward to continuing to campaign with her in the years ahead.

Deputy leader Angela Rayner said Ms Formby had been “a great servant of our movement for many years and blazed a trail as one of our highest achieving women”.

“She goes with our thanks and gratitude, and I’ve no doubt she will stand squarely behind us as we continue to fight for social justice and the Labour government our country so desperately needs,” Ms Rayner added.