Polls show the Tories are set to lose their Wakefield seat and may also be defeated in Tiverton & Honiton if Labour supporters vote tactically.
But Mr Johnson insisted that he is “hopeful” of a positive result.
Speaking to journalists before travelling to Rwanda for a major Commonwealth summit the PM was asked if he would quit if voters turned against his party.
Mr Johnson said: “Come on, it was only a year ago that we won the Hartlepool by-election, which everybody thought was – you know, we hadn’t won Hartlepool for – I can’t remember when the Tory party last won Hartlepool – a long time.”
“I don’t think it ever had. Governing parties generally do not win by-elections particularly not in mid term. You know, I’m very hopeful, but you know, there you go. That’s just the reality.”
Pressed on whether he would quit if the Tories lost both seats, he added: “Are you crazy.”
Election guru Sir John Curtice has warned that a double defeat would put the government at risk of losing its electoral footing.
Polls close in both constituencies at 10pm today, with the results expected between 4am and 6am tomorrow.
If the government lost both seats, it would be the first time this has happened in more than 30 years.
Mr Curtice said the number of Labour supporters willing to lend their vote to the Liberal Democrats in Tiverton & Honiton would be vital.
Earlier this week Mr Johnson accused the Lib Dems of being the enablers and acolytes of Labour and branded them “the karma chameleons of politics.”
Labour is expected to take back the West Yorkshire seat of Wakefield, which was won by the Tories in 2019 for the first time since 1932 with a 3,358 majority.
The conviction of Imran Ahmad Khan, the former Conservative MP, for sexually assaulting a 15-year-old boy means the opposition party should storm home.
In Devon’s Tiverton and Honiton, Neil Parish, the Tory MP since 2010, resigned after admitting he had watched pornography on his phone in the House of Commons.
The Lib Dems are hoping to overturn a majority of nearly 25,000.
If the Conservatives lose both seats, it would be the first time since John Major’s government in 1991.