In a speech he said Britons, like Ukrainians, had the instinct “to choose freedom” and cited the 2016 vote to leave the EU as a “recent example”.
The comments have caused anger among politicians both in the UK and Europe.
Donald Tusk, the former president of the European Council, called the comments offensive.
Conservative peer Lord Barwell said voting in a referendum was not “in any way comparable with risking your life” in a war, while Liberal Democrat leader Sir Ed Davey said it was an “insult” to Ukrainians.
The row comes as the prime minister strongly urged China to condemn the Russian invasion in an interview with the Sunday Times. He suggested Beijing was having “second thoughts” about its neutral stance.
He said: “I know that it’s the instinct of the people of this country, like the people of Ukraine, to choose freedom, every time. I can give you a couple of famous recent examples.
“When the British people voted for Brexit in such large, large numbers, I don’t believe it was because they were remotely hostile to foreigners.
“It’s because they wanted to be free to do things differently and for this country to be able to run itself.”