Rahul Gandhi has resigned as leader of India’s main opposition Congress party, ending weeks of speculation.

In his resignation letter, which he tweeted on Wednesday, he took responsibility for the party’s defeat in the recent general election.

He had already announced his intention to resign, but party leaders had hoped to change his mind.

Mr Gandhi’s father, grandmother and great grandfather were all former prime ministers.

In the letter he added that while he had no “hatred or anger” towards India’s ruling Bharatiya Janata Party (BJP), “every living cell in my body instinctively resists their idea of India” which he said was based on differences and hatred.

Mr Gandhi was also the face of Congress when it suffered its worst defeat in 2014, winning just 44 of India’s 543 seats. This year it did marginally better with 52 seats, but many still called it a “humiliating performance”.

Mr Gandhi also lost his own seat in his family constituency of Amethi in the northern state of Uttar Pradesh, though he is still a MP because he won a second seat in the southern state of Kerala.