Goals from Robert Lewandowski, Phillipe Coutinho, and Ivan Perisic helped the defending Bundesliga champions seal a comfortable victory over Cologne.
Jadon Sancho, 19, brought Dortmund to life in the second half, driving home a much-needed equaliser before grabbing an injury-time assist to seal its comeback.
Jhon Cordoba's hat-trick has saved the team as it relegates from Bundesliga's last season.
The 30-year-old striker posted on Instagram that he will approach the Court of Arbitration for Sport in Lausanne, Switzerland, in a bid to play for German second-division side Cologne.
Major urban areas including Stuttgart, Frankfurt and Berlin have been slapped with legal orders to cut emissions, while Hamburg decided of its own accord to expel the worst polluters from some zones.
Witnesses reported that the man had claimed to be a member of the Islamic State jihadist group, and police said they were investigating whether his motive was terrorism and whether he acted alone or with others.
Germany is on high alert for militant attacks, almost two years after a Tunisian Islamist rammed a hijacked truck into a Christmas market in central Berlin, killing 11 people as well as the driver.
Police snipers were stationed on rooftops and the area was cordoned off after the city authorities cancelled plans for up to 25,000 people to be allowed to gather outside the mosque.
The inauguration will be the closing event of Erdogan's three-day state visit, aimed at repairing frayed ties with Berlin after two years of tensions.
German police commandos on June 12 stormed the Cologne apartment of the 29-year-old Tunisian identified only as Sief Allah H. and discovered "toxic substances" that turned out to be ricin.