PARIS — Faced with a surge in coronavirus cases driven by the Omicron variant, President Emmanuel Macron of France said Wednesday that he wanted to “piss off” millions of his citizens who refuse to get vaccinated by squeezing them out of the country’s public spaces.

By shocking the nation with a vulgarity three months before presidential elections, Mr. Macron was relaying not only a public health message, but also a political one. He appeared to be calculating that tapping into the growing public anger against the unvaccinated held more potential electoral rewards than the risk of angering an anti-vaccination minority whose support he has little hope of ever getting.

Using his harshest language yet to urge the recalcitrant to get their shots, Mr. Macron said he would not “throw them in prison” or “vaccinate them by force.” But he made it clear he meant to make their lives harder.

In doing so, Mr. Macron, an inveterate political gambler who became the nation’s youngest leader ever five years ago, effectively kicked off his campaign for re-election Wednesday, drawing clear lines between his supporters and opponents. He also moved the focus of debate away from themes like immigration and Islam that have dominated the political race so far and that are advantageous to his strongest rivals, on the right and far right.