DORTMUND, Germany (AP) — Juergen Klopp will leave Borussia Dortmund at the end of this season after seven years in charge, stepping down after a dismal season for the club.

Dortmund says it has agreed with Klopp to terminate his contract, which was valid through 2018, on June 30.

Klopp led Dortmund to Bundesliga titles in 2011 and 2012, won the German Cup in 2012 and reached the 2013 Champions League final.

Dortmund was runner-up to Bayern Munich in the Bundesliga in 2013 and 2014 but its form slumped this season.

The team has clawed its way off the bottom and is now 10th in the 18-team league, six points clear of the relegation zone with six matches to play. However, it has lost its last two matches.

Copyright 2015 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.