At least five people, including a 9-year-old child, were killed in the attack, which took place in the eastern city of Magdeburg. The authorities are still seeking a motive.
It was not the first online intervention by Elon Musk, the entrepreneur and adviser to Donald Trump, on behalf of once-fringe anti-immigrant parties in Europe.
If polls are correct, Olaf Scholz’s successor could be the 69-year-old leader of the Christian Democratic Union. He is offering to get the German economic engine humming again.