The 27-year-old defender moved to BVB from Barcelona in summer 2016, but has struggled for first-team football in recent months and leaves the club having made just 12 Bundesliga appearances this season.
"I can hardly find the words to describe all the moments and feelings I've experienced here in the last 18 months," an emotional Bartra told the official BVB website. "I'd never have thought it possible to experience so much love and support from one of the best football families in the world. You're an example to follow. I always gave my all. We were able to win a trophy again after a few years without one and celebrate it together. I'll never forget that, or any of the other moments."
Bartra forged a special bond with the Dortmund fans, even more so after being injured when three bombs exploded next to the team bus before Die Schwarz-Gelben's UEFA Champions League quarter-final first leg against Monaco on 11 April of last year.
Watch: Bartra the Battler
"Marc is a wonderful person and a great footballer, who won us all over straight away," said Dortmund CEO Hans-Joachim Watzke. "Unfortunately he was subject to something absolutely terrible in Dortmund through the cowardly attack [on the team bus]. Given that backdrop, we respect Marc's desire to return to his homeland and leave all that behind him. As we feel indebted to Marc in a special way we were very accommodating in negotiating this transfer. Borussia Dortmund wishes Marc and his family all the best for the future. We'll always be connected with each other."
The Spain international, who won the DFB Cup with BVB in May 2017, turned out 51 times in all competitions for the Ruhr district giants.