ANNABERG-BUCHHOLZ, Germany — Taking the stage, Chancellor Angela Merkel thanked the thousands of Germans who had turned out at a recent campaign rally, and then leveled her gaze at a small but noisy knot of right-wing protesters yelling and blowing whistles at the back of the square.

“Some want to listen, but others can only shout,” the chancellor scolded, singling out the protesters from the far-right Alternative for Germany party. “That is what separates us; some want to get things done, others just yell.”

With that, Ms. Merkel defused what could have been an ugly challenge at her rally in Annaberg-Buchholz, near the eastern border. As Ms. Merkel seeks a fourth term in elections on Sept. 24, she has done much the same to what had once seemed like a potent threat from the far right in general.

Barely six months ago, after more than 11 years in power, the chancellor was vulnerable. Her immigration policies were unpopular and had buoyed a far right that was surging across Europe. Ms. Merkel herself appeared ambivalent about another run as polls showed voters tiring of her.