Rishi Sunak has insisted the Conservatives can still win the next election, despite suffering two damaging by-election defeats.
Labour and the Lib Dems overturned big Tory majorities in Somerton and Frome, and Selby and Ainsty constituencies.
But the Tories held the London seat of Uxbridge and South Ruislip, despite predictions they could lose there too.
The result showed the next election was not a "done deal" for Labour, the prime minister said.
He added that the results showed his government needed to "double down" on his signature pledges on the economy and illegal migration.
But Labour leader Sir Keir Starmer said its "historic" victory in Selby showed "just how powerful the demand for change is" ahead of the next general election, expected to take place next year.
The Tories' narrow victory in the suburban seat of Uxbridge, which they won by 495 votes, spared Mr Sunak the humiliation of being the first PM for 55 years to lose three by-elections in one night.
The party managed to capitalise on local anger over the planned expansion of the Ultra Low Emissions Zone (Ulez), a tax on polluting vehicles, to outer London boroughs by the capital's London mayor.
Visiting a cafe in the constituency, Mr Sunak said it showed that people would vote Conservative when confronted with the "reality" of Labour in power.
But the other two results suggest the Tories face a difficult path to possible victory at the next election, with the party trailing Labour in the polls nationally by significant margins.
Asked what the defeats meant for his party, Mr Sunak replied: "The message I take away is that we've got to double down, stick to our plan and deliver for people."
'Electoral Armageddon'
He vowed to renew his focus on his government's five flagship priorities of halving inflation, growing the economy, reducing debt and NHS waiting times, and stopping small boat crossings.
Former Cabinet minister Jacob Rees-Mogg told BBC Radio 4's Today programme that the Conservative Party needed to back the prime minister, adding: "Tory MPs including me need to row in behind the prime minister, because divided parties don't win elections."
However, a former cabinet minister on the right of the Conservative Party told the BBC the "eye-watering swings" in Selby and Somerton showed the party needs a "complete change of direction".
"Uxbridge provides no get-out-of-jail-free card for Rishi," they added.
"It is becoming increasingly clear that a failure by the party leadership to act now and change course risks electoral Armageddon."
Progress towards the prime minister's pledges has so far been slow, with inflation in particular falling more slowly than predicted by many economists at the start of the year.
Conservative chairman Greg Hands conceded there was a "lot of work still to be done" to meet the promises, adding they "weren't designed to be an easy thing to meet".
Labour won with a 23.7% swing in the rural North Yorkshire seat of Selby and Ainsty, breaking the record for the largest Tory majority it had overturned at a by-election since 1945.
And a 29% swing to the Liberal Democrats in the Somerset seat of Somerton and Frome showed they could be a stronger challenger to the Tories in the West Country than at the last election in 2019.
He added that its two defeats in Somerset and Yorkshire had both seen tactical voting to eject the Conservatives locally, spelling "bad news" for the governing party.
Liberal Democrat deputy leader Daisy Cooper said her party was hopeful it would be able to persuade Labour voters to lend them their votes to oust the Tories, in seats where they are the main challengers.
She added there were around 15 seats in the West Country with smaller Tory majorities than Somerton and Frome, which the Lib Dems would be targeting at the next general election.