Conservative candidate Caroline Johnson has won the Sleaford and North Hykeham by-election, which saw Labour come in fourth behind UKIP and the Liberal Democrats.
The Tory party held onto the seat which became vacant after MP Stephen Phillips quit, citing “irreconcilable policy differences” with the government.
Dr Johnson won 17,570 votes to beat UKIP’s Victoria Ayling, who had 4,426.
Labour slipped from second place in the 2015 general election to fourth.
Consultant paediatrician Dr Johnson said her election would boost Theresa May’s support on Brexit.
She said: “I look forward to strengthening the government’s majority in Parliament so Theresa May, our prime minister, can get on with the job of triggering Article 50, leaving the European Union and building a country and economy that works for everyone.”
UKIP’s ‘great result’
The seat has returned Conservative MPs since it was formed in 1997 and Mr Phillips, who resigned in November, had a majority of more than 24,000 votes in 2015.
Although he backed leaving the EU, he had since been critical of the government’s approach to Brexit.
Dr Johnson won with a 13,144 majority after securing 53.51% of the votes, while UKIP came in second with 13.48%.
Liberal Democrat candidate Ross Pepper won 3,606 votes to clinch third, narrowly ahead of Labour’s Jim Clarke who was fourth with 3,363 votes.
UKIP had campaigned hard in the Lincolnshire seat, an area which voted heavily to leave the EU.
The party’s former leader Nigel Farage and his successor Paul Nuttall had been on the campaign trail in the constituency, supporting Ms Ayling – a former Conservative who stood for the Tories in Great Grimsby in 2010.
Ms Ayling said coming in second was a “great result” for UKIP as it showed “more people are trusting us to deliver”.
Mr Nuttall said the result was a “really good way to get my leadership off the ground”.
He added: “If someone would have offered me second place at the beginning of the campaign, considering we were in the middle of a leadership election and the party resembled a bit of a shambles over the summer, I would have bitten their hand off.”
Liberal Democrat leader Tim Farron said his party’s “strong result” showed they were “back as an electoral force” in areas that had voted to leave, as well as remain, in the EU.
He went on: “With Labour yet again nowhere, and after losing their deposit in Richmond, the Liberal Democrats are the real opposition to the Conservative Brexit government.”
Labour MP Vernon Coaker said the result was not what his party had hoped for and said the campaign had been a challenge because of the focus on Brexit.
He said: “The messages about the A&E, the NHS, the messages about infrastructure, all of that got lost to an extent in the swirl around Brexit.
“But we’re proud of what we did. We kept our deposit which some people said we were going to lose.”
The turnout for the by-election was 37.1% according to North Kesteven District Council, down from 70.2% at the general election last year.