Zac Goldsmith, who lost his seat in the general election, has been given a life peerage so that he can keep his role as environment minister.

The former MP for Richmond Park in Greater London was beaten by the Liberal Democrats by nearly 8,000 votes last week in one of the few high-profile Conservative losses of the election.

The government confirmed on Thursday that Goldsmith would be reappointed to his old post as a minister in the department for the environment, food and rural affairs and the department for international development.

“The Queen has been pleased to signify her intention of conferring a peerage of the United Kingdom for life on Zac Goldsmith,” said the announcement. A government spokesperson confirmed Goldsmith would continue to attend cabinet meetings.

The confirmation follows widespread suggestions that the move was planned.

Play Video 1:06 Zac Goldsmith loses seat to Lib Dems: 'All good things must come to an end' – video





Goldsmith, the son of the billionaire businessman James Goldsmith, is a long-time ally of Johnson and his partner Carrie Symonds. His London mayoral campaign was accused of being racist and Islamophobic for trying to suggest that Labour’s Sadiq Khan had links with terrorists and extremists.

The shadow cabinet office minister, Jon Trickett, said: “It says everything you need to know about Boris Johnson’s respect for democracy that he has ignored the voters of Richmond Park and appointed Goldsmith to government.”

“The public deserve better than a government appointed by ‘jobs for mates’. At a time when the Conservatives are investigating racism in their party, they’ve appointed the person who ran an overtly racist campaign against Sadiq Khan. Zac Goldsmith is not fit to hold any government position.”

It is the second time in a week that Johnson has chosen to make a colleague a life peer in order to keep them in his cabinet. Nicky Morgan, who stood down as an MP ahead of the election, was appointed to the House of Lords so that she could stay on as culture secretary.

Responding to earlier reports that Goldsmith was in line for a peerage, Darren Hughes, chief executive of the Electoral Reform Society, said: “The bloated House of Lords is already packed full of defeated and former MPs – over 200 of them. Politicians shouldn’t be rewarded with votes on our laws for life after losing their seat.

“This issue we’ve seen across parties for years and makes an absolute joke of democratic accountability. Our second chamber should not be some absurd insurance policy for trounced MPs.”

Goldsmith has been an outspoken advocate for voters having the right to recall MPs outside a general election. Putting a proposal before parliament in 2014, he said: “What is at stake now is a matter of principle. Do we trust our voters to hold us to account or not?”