LONDON — Former Prime Minister David Cameron, who has stayed out of the public eye since leaving Downing Street in July, has decided to step down from his position in Parliament and put an end to his political career.

Cameron’s surprise announcement Monday will trigger a by-election in the county of Witney in Oxfordshire, which has been a safe seat for his Conservative Party for several decades.

Cameron, 49, won a general election in 2015, but his political fortunes shifted overnight in June when British voters rejected his pleas and decided to leave the European Union.

He announced the next morning he would step down as prime minister but planned to stay on in Parliament. On Monday, he said he had concluded that it made more sense for him to leave public office altogether.

“In my view, the circumstances of my resignation as prime minister and the realities of modern politics make it very difficult to continue on the backbenches without the risk of becoming a diversion to the important decisions that lie ahead for my successor in Downing Street and the Government,” Cameron said.

The former prime minister said he fully supports successor Theresa May, now charged with carrying out the voters’ mandate to extricate Britain from the 28-nation EU bloc.

May said in a statement she had been proud to serve in Cameron’s government, where she held the important role of home secretary, and said the government had accomplished great things under his leadership.

Cameron did not announce his future plans. He became party leader in 2005 and prime minister in 2010, when he led a coalition government that included the Liberal Democrats.

His Conservatives won an outright majority in 2015, strengthening his hand considerably, but he was brought down by voters’ unhappiness with the EU, in part because of unchecked immigration from other EU countries into Britain.

The date for the by-election has not yet been set.

He promised to support the Conservative Party candidate chosen to replace him in the by-election that will be held in order to fill the Parliament vacancy.