Klopp, who led Dortmund to two Bundesliga titles and the Champions League final in 2013, will see out what has been a frustrating season for the club but leave on June 30.
"I have said over the years that when I have the feeling I am no longer the perfect coach for this extraordinary club, I'd say it," said Klopp, whose contract was valid through 2018. "We reached the decision together. You can't imagine how difficult it is when you have something so wonderful as here."
The club has not yet identified a successor, nor would it comment on speculation linking former Mainz coach former Mainz coach Thomas Tuchel with the post.
"Safety first," Dortmund CEO Hans-Joachim Watzke said.
Klopp took over at Dortmund in 2008, led the club to the Bundesliga title in 2011, the league and German Cup double the following year, and the Champions League final in 2013.
Dortmund was runner-up to Bayern Munich in the Bundesliga in 2013 and 2014 but its form has slumped this season. The club made its worst ever league start and was in last place in February before carving out some breathing space with a seven-game unbeaten run. Still, Dortmund was 37 points behind Bayern Munich with six Bundesliga games remaining.
"The steps we took this season weren't big enough," Klopp said.
The meek Champions League exit to Juventus also increased the pressure. Dortmund has only the German Cup and European qualification to aim for this season.
"My last dream is to get the best possible position in the table and to celebrate one last time, for a good reason, on Borsigplatz," said Klopp, referring to the Dortmund square where the club celebrates titles with fans.
The 47-year-old Klopp, who has been linked to clubs in England and Spain, said he has "nothing in the hand" from any other team and had no plans for a sabbatical, "though it could of course be that I have to take one, or whatever a free half-year is called, I don't know."
A visibly emotional Watzke thanked Klopp for his service.
"We had a very special relationship, one of trust and friendship. So for us this is very hard," Watzke said. "After seven years of wonderful work, the thanks of every Borussen (club supporter), the eternal thanks of every Borussen, is there. The only thing that comforts me at this time is that our friendship will remain."
After the difficulties of the season, Klopp said he simply felt the time came for him to move on.
"This club deserves to be coached by the 100 per cent-correct coach and from that point of view I have to come to this decision," Klopp said. "There's a stage at which you start planning for the future, and if you're not 100 per cent certain that you can be there next season, then you can't plan for it. There was no falling out between me and the team and there won't be one either."
Looking back, Klopp said he was proud of what the team had achieved.
"We were able to create a wonderful piece of history," Klopp said. "It's very unusual for a story to last seven years in football."Suggest a correction