After a bumpy first two months on the campaign trail, Gov. Andrew M. Cuomo will arrive at the New York State Democratic convention this week with surer political footing.

Hillary Clinton will deliver the keynote address on Wednesday and endorse Mr. Cuomo’s candidacy for a third term. He is widely expected to win the overwhelming support of party leaders to get an automatic spot on the ballot.

And in a fortuitous twist, the person whom Mr. Cuomo most wants to center his campaign against in the primary — President Trump — will be only a few miles away speaking at an immigration forum, allowing the governor a ready-made contrast.

His actual primary opponent, Cynthia Nixon, will be much closer: She plans to attend the Democratic convention (“I won’t be scared out of the room,” she said in a statement), being held at Hofstra University on Long Island, but she’ll be playing on turf largely controlled by party officials appointed by and loyal to Mr. Cuomo.