It was the first time Jose Mourinho has tasted defeat in the Premier League at Stamford Bridge in 78 games.
Samuel Eto'o put the hosts ahead on 12 minutes when volleying home Willian's corner from the left.
But Connor Wickham - who scored a brace in Sunderland's midweek draw at Manchester City - levelled six minutes later when slotting home from close range after Mark Schwarzer could only parry Marcos Alonso's long-range effort from a corner.
Ramires looked lucky to stay on the field after appearing to catch Sebastian Larsson with an elbow, and the Black Cats won the game with eight minutes remaining after subsitute Jozy Altidore was fouled by Cesar Azpilicueta in the box.
On-loan Liverpool player Borini scored the resulting penalty to hand Sunderland a relegation lifeline, with the Black Cats now just three points from safety.
The stunning result means leaders Liverpool can open up a five-point advantage over the second-placed Blues with victory at Norwich on Sunday.
It was a bad day for the Blues, whose coach Rui Faria was sent to the stands, with Mourinho having to drag him away from fourth official Phil Dowd as the hosts' protests turned ugly after Sunderland took their late lead.
Ramires could also be facing a premature end to his campaign if he receives punishment for appearing to strike Larsson. The FA's disciplinary department will be likely to review footage of the incident, and are able to impose sanctions given referee Mike Dean took no action during the match. The midfielder's two red cards this season could see him receive a five-match ban.
Eto'o gave the Blues the lead when side-footing home on the volley after Willian's corner, but notions of a Chelsea victory march were quickly trampled by Wickham's tap-in equaliser.
Chelsea's defending was poor from Larsson's corner, leaving Alonso in acres of space to tee up a drive on the edge of the area. His effort should never have troubled Schwarzer - in for Petr Cech, who was suffering a virus - but the 41-year-old spilled what should have been a routine save, gifting Wickham his third league goal of week.
Oscar chipped a curling shot on target form the edge of the area as Chelsea rallied, but Vito Mannone was wise to it.
John Terry had the ball in the back of the net just past the half-hour, only for Nemanja Matic's penalty-box foul on Jack Colback to deny the captain.
Mannone almost handed the lead back to Chelsea when flapping Branislav Ivanovic's header onto his own crossbar, before he was able to smother the ball at the second attempt.
Mannone parried Matic's 20-yard shot before denying Mohamed Salah on the rebound.
Borini's clearing header struck team-mate Alonso's arm in the Sunderland area, but referee Dean rightly waved away penalty appeals.
Ramires was bustled off his cue by Larsson when aiming to head into the empty net. Dean took no action and moments later, Ramires meted out his own brand of retribution by flinging a stray arm into Larsson's face just yards away from the referee.
Early in the second period, Willian cantered clear on the counter, teeing up Eto'o at the perfect moment, only for the striker to clip the shot just wide.
Willian then cut the ball back into the path of substitute Ba, but he shot wide with the goal gaping.
Replacement Fernando Torres injected immediate pace, before firing high above the bar with an overhead kick and forcing a corner from another effort.
The ex-Liverpool man then headed straight at Mannone after a lumped ball into the box.
Azpilicueta then felled Altidore in the box after slipping and failing to recover, handing Sunderland a penalty.
Borini coolly slotted the spot-kick and Chelsea were unable to make five minutes of added time count.