John Bercow says he will stand down as Commons Speaker at the next election or on 31 October, whichever comes first.
Speaking in Parliament, Mr Bercow said his 10-year “tenure” was nearing its end and it had been the “greatest honour and privilege” to serve.
If there was no early election, he said leaving on 31 October would be the “least disruptive and most democratic” time to go.
The ex-Tory MP succeeded the late Michael Martin as Speaker in 2009.
He has faced fierce criticism from Brexiteers who have questioned his impartiality.
In a break from normal convention, Mr Bercow was facing a challenge from the Conservatives in his Buckingham constituency at the next election – whenever it is called.
His wife, Sally, was in the public gallery as he made his announcement.
Mr Bercow said he had decided at the time of the 2017 election that this would his last Parliament as Speaker.
If MPs reject calls for an early election later on Monday, as seems likely, he said it was important an “experienced figure” chaired debates in the final week of October leading up to the UK’s possible exit from the EU.
He warned that if the appointment of his successor was left until after the next election, newly-elected MPs might find themselves being “unduly influenced” by party whips in their choice of figure.
“It will mean a ballot is held when all members have some knowledge of the candidates. This is far preferable to a contest at the start of a Parliament where new MPs will not be similarly informed.
“We would not anyone want a anyone to be whipped senseless, would we?”
In an emotional speech, he said he had been proud to stand up for the interests of MPs and to act as the “backbenchers’ backstop”.
“Throughout my time as Speaker, I have sought to increase the relative authority of this legislature for which I will make absolutely no apology to anyone, anywhere, at any time.”
Mr Bercow received a standing ovation from the Labour benches after announcing his imminent departure, but most Tory MPs stayed in their seats.
Labour leader Jeremy Corbyn led tributes, saying the Speaker had stood up for and promoted democracy, adding that the “choice and timing” of his exit date was “incomparable”.
For the government, Michael Gove said his determination to give MPs increased opportunities to hold the government to account were “in the best tradition of Speakers”.
When he was first elected, Mr Bercow said he intended to serve no more than nine years in the job.
The Speaker is elected by all MPs in the House by secret ballot.
By tradition, the role alternates between the two major parties. If this is maintained, the next Speaker will be a Labour MP.
Potential successors to Mr Bercow include Commons deputy Speaker Lindsay Hoyle and Harriet Harman, the former Labour deputy leader and the longest-serving female MP in the House.