SÃO PAULO — The front-runner in Brazil’s presidential election, Jair Bolsonaro, was in a serious but stable condition on Friday, recovering from near-fatal stabbing amid predictions that the attack will lift his standing and ratchet up tensions in the most uncertain vote in years.

“I’m well and getting better,” he posted on Twitter Friday, one day after he was attacked with a knife during a campaign event in the southeastern state of Minas Gerais. Video of the attack was shared on social media.

After emergency surgery to repair perforations to his intestines and an abdominal vein at a local hospital, he was transferred on Friday to Albert Einstein Hospital in São Paulo.

Mr. Bolsonaro, a former army captain, is a deeply polarizing figure, at once the most popular and most reviled candidate in a presidential race that remains splintered just weeks before the Oct. 7 vote.