"We played really well in the first half and did everything right, we weren't rushed, but our opponents worked us out," Dortmund coach Jürgen Klopp said. "Everything which went well for us before the break, didn't afterwards."
With Arsenal losing 3-1 at Olympiakos, Marseille were bound only for the Europa League and third place in Group F before netting two goals in two minutes at the end of the second half with sub Mathieu Valbuena scoring the superb winner.
Marseille boss Didier Deschamps hailed his side for "doing me proud as we endured a very difficult first half. We were still 2-1 down on 85 minutes and were close to getting nothing at all - but we kept believing right to the end."
Goals by Poland midfielder Jakub Blaszczykowski and Germany defender Mats Hummels had put Dortmund 2-0 up early in the first-half.
France striker Loic Remy pulled a goal back for Marseille at the end of the first-half before Andre Ayew levelled in the 85th minute and then Valbuena completed the fairytale two minutes later.
Victory sees Marseille finish second behind Arsenal in Group F with Olympiakos third and into the Europa League while Dortmund bow out of Europe. Borussia came into the game with only a mathematical chance of reaching the knock-out phase, needing at least a 4-0 win to cancel out their 3-0 defeat at Marseille at the end of September.
Marseille had been just eight minutes from booking a spot in the next round a fortnight ago before a late strike sealed Olympiakos' 1-0 win at Stade Velodrome which took the group to the wire.
The Germans put up a fight at their sold-out Signal Iduna Park stadium to take the lead on 23 minutes when Blaszczykowski -- known as Kuba for short -- barged his way into a packed penalty area and stabbed home.
Dortmund lost their captain Sebastian Kehl six minutes later when he was left pole-axed on the turf after taking a full kick in the face from Marseille's Cameroon defender Stephane Mbia, who was competing for the ball.
"There is nothing broken, which is good," Klopp reported. "The eye will be examined as the vision is a little blurry."
The African was booked for the challenge, which sent Kehl sent to hospital, and English referee Howard Webb had no hesitation pointing to the spot for Dortmund Hummels to fire home on 32 minutes to make it 2-0.
Borussia goalkeeper Roman Weidenfeller took over the captaincy from Kehl, Brazilian midfielder Antonio da Silva slotted into defence and Dortmund kept attacking looking for a third goal before half-time.
Having spent most of the first half under siege, Marseille pulled a goal back with virtually their first genuine attack and the last kick of the first half.
There was already four minutes of added time on the clock when winger Morgan Amalfitano swung in an excellent cross to Remy and he headed home in the 49th minute of the first half to make it 2-1 at the break.
The Germans were heading for a worthless win until Amalfitano's cross found Ayew unmarked and he headed home on 87 minutes before Valbuena found the top corner of the net from 16 metres out with a superb curling shot.