Labour has won the Wakefield by-election with 13,166 votes – a majority of 4,925 – taking the traditional Red Wall seat back from the Conservatives.
NHS worker Simon Lightwood will now represent the West Yorkshire city in the Commons.
Tiverton and Honiton and Wakefield by-elections: Follow live updates
The ballot was triggered by the resignation of Tory MP Imran Ahmad Khan, who quit after being found guilty of sexually assaulting a 15-year-old boy.
The seat had been represented by Labour since 1932, but was taken by Mr Khan in Boris Johnson’s 2019 landslide general election win.
The result is the first test of the prime minister’s leadership since last month’s confidence vote.
The Conservatives also appeared to be heading for a defeat in the Tiverton and Honiton by-election as the Liberal Democrats claimed an “historic victory” – though counting is still under way.