Frank Lampard scored twice to become Chelsea's all-time leading scorer as the Blues came from behind to win at relegation-threatened Aston Villa.
Christian Benteke put Villa ahead with a strong run and finish, while Chelsea had Ramires sent off before half-time.
After the break Benteke saw a red card and Lampard fired his side level.
The midfielder then collected his 203rd Blues goal to break Bobby Tambling's record and all but secure their place in next season's Champions League.
Lampard has scored 13 Premier League goals against Aston Villa, his most against any single opponent
Chelsea sit third in the table with one game left and only an unlikely mathematical scenario can deny them a top-four place.
Arsenal could end up above them and Tottenham can finish on the same points, but Chelsea's goal difference is 17 better than that of Spurs.
Although the result leaves Villa five points clear of the relegation zone in 13th, they have played a game more than every team beneath them.
Paul Lambert's side will feel hard done by, but Lampard's intervention sums up the impact he has made throughout his career as he exploited a defence that has now gone 21 league games without a clean sheet.
For so long it seemed Villa were heading for a sixth win nine matches to secure survival, their newfound confidence clear for all to see.
Benteke opened the scoring when he met Brad Guzan's long ball forward with a touch to Yacouba Sylla, took the return pass, ghosted past Gary Cahill and planted an assured finish past Petr Cech at the near post.
It was the Belgian's 19th goal of an impressive debut Premier League season and his 23rd in all competitions.
Villa Park was rocking and the noise level rose again when Fabian Delph rifled narrowly off target before, in the 19th minute, applause rang out for newly retired captain Stiliyan Petrov, who has been forced to quit the game
as he continues his battle with leukaemia.
Benitez pleased after 'dramatic' win
Chelsea worked hard to restore parity - Guzan denied Demba Ba when one-on-one and pushed Lampard's free-kick on to a post - but Villa held firm and their prospects improved when the visitors had Ramires sent off.
The Brazilian had already been cautioned for a challenge on Benteke when he caught Gabriel Agbonlahor with a high foot.
That saw the momentum swing towards Villa and they dominated the start of the second half, with an Agbonlahor-led counter-attack setting the tone before both he and Joe Bennett went close to doubling the lead.
But the hosts' progress faltered as Benteke, booked for catching Cesar Azpilicueta with his elbow in the first half, was shown a second yellow card for a high foot that connected with John Terry.
Two minutes later, Eden Hazard found Lampard and he produced a fizzing left-foot finish that left Guzan with no chance.
Petrov waves goodbye to Villa fans
Chelsea pressed for the winner and Cahill's strike was stopped on the line by Sylla, and although TV replays showed Ba's follow up may have crossed the line it was not given and Ashley Westwood cleared.
Terry - and later Hazard - went off injured, a worry for Rafael Benitez ahead of Wednesday's Europa League final.
But the Blues were left celebrating after Lampard rounded off a brilliant late move with the goal that rewrites the record books.
Aston Villa manager Paul Lambert:
"We should have won the game. I thought we looked great and played good football, we had a good tempo. Some of the decisions today were bizarre. The referee missed the John Terry one, he's taken down Yacouba Sylla. You've got to be big enough to make that decision.
"We were so far in control of that game. We didn't deserve that - we were excellent.
"I thought we should have had a penalty. There were so many decisions that were poor."
Chelsea manager Rafael Benitez:
"It [all but qualifying for the Champions League] was a great achievement. With a lot of games we have played, it was difficult but we did well.
"It was a dramatic game. The sending-off for us was a big problem. We had to change our game plan at 11 v 10. When Christian Benteke was sent off it made a difference.
"We have to wait and see how the injured players are. John Terry has twisted his ankle and we have to wait for a scan. Hazard hurt his hamstring and we will have to wait and see."
Centre by Joe Bennett, Branislav Ivanovic makes a clearance. Outswinging corner taken right-footed by Ashley Westwood from the right by-line, clearance by Cesar Azpilicueta.
Outswinging corner taken from the right by-line by Ashley Westwood.
Shot by Yacouba Sylla from 20 yards. Branislav Ivanovic gets a block in.
Outswinging corner taken left-footed by Juan Mata played to the near post. Unfair challenge on Fernando Torres by Eric Lichaj results in a free kick. Free kick taken by Juan Mata. David Luiz takes a long range shot clearing the crossbar.
Eden Hazard provided the assist for the goal.
87:52 Goal scored
Goal! - Frank Lampard - A Villa 1 - 2 Chelsea A goal is scored by Frank Lampard from inside the six-yard box low into the middle of the goal. Aston Villa 1-2 Chelsea.
Substitution Demba Ba leaves the field to be replaced by Fernando Torres.
Shot from 20 yards from Ashley Westwood. Save by Petr Cech. Andreas Weimann is flagged offside by the assistant referee. Petr Cech takes the indirect free kick.
Frank Lampard takes a shot. Bradley Guzan makes a comfortable save.
Joe Bennett takes a deflected shot. Gary Cahill gets a block in.
Free kick taken by Ashley Westwood.
Booking Frank Lampard receives a yellow card for unsporting behaviour.
Andreas Weimann fouled by Frank Lampard, the ref awards a free kick.
Corner taken by Juan Mata, Nathan Baker manages to make a clearance.
The ball is sent over by Cesar Azpilicueta.
Eric Lichaj challenges Eden Hazard unfairly and gives away a free kick. Shot on goal comes in from David Luiz from the free kick, save made by Bradley Guzan.
Eden Hazard fouled by Ashley Westwood, the ref awards a free kick. Juan Mata shoots direct from the free kick.
The assistant referee signals for offside against Joe Bennett. Petr Cech takes the indirect free kick.
Centre by Cesar Azpilicueta, Frank Lampard produces a header from inside the area that goes over the crossbar.
Substitution Branislav Ivanovic is brought on as a substitute for John Terry.
Outswinging corner taken by Juan Mata.
Juan Mata delivers the ball, blocked by Eric Lichaj. Corner from the left by-line taken by Juan Mata, Gary Cahill takes a shot. Clearance made by Andreas Weimann.
Fabian Delph has an effort from just inside the box that misses to the left of the target.
Ashley Westwood takes a outswinging corner.
A cross is delivered by Andreas Weimann, Petr Cech makes a comfortable save.
The assist for the goal came from Eden Hazard.
60:18 Goal scored
Goal! - Frank Lampard - A Villa 1 - 1 Chelsea Goal scored by Frank Lampard from just outside the area to the top left corner of the goal. Aston Villa 1-1 Chelsea.
Direct free kick taken by Petr Cech.
Dismissal Red card for Christian Benteke.
Foul by Christian Benteke on John Terry, free kick awarded.
Shot from outside the penalty box by Fabian Delph goes wide right of the goal.
Joe Bennett takes a shot. Blocked by Cesar Azpilicueta. Corner taken right-footed by Ashley Westwood.
Yacouba Sylla concedes a free kick for a foul on David Luiz. David Luiz takes the direct free kick.
Effort from the edge of the box by Gabriel Agbonlahor goes wide of the left-hand post.
Yacouba Sylla takes a shot from just inside the penalty box which clears the bar.
Unfair challenge on David Luiz by Fabian Delph results in a free kick. Gary Cahill restarts play with the free kick.
Demba Ba is flagged offside by the assistant referee. Free kick taken by Bradley Guzan.
Andreas Weimann is ruled offside. Indirect free kick taken by Cesar Azpilicueta.
Gabriel Agbonlahor takes a shot. Gary Cahill gets a block in.
The second half kicks off.
Substitution David Luiz on for Victor Moses.
45:00 +2:25 Half time
Half Time The first half comes to an end.
Gabriel Agbonlahor takes a shot. Blocked by Gary Cahill.
Andreas Weimann fouled by John Terry, the ref awards a free kick. Eric Lichaj takes the free kick.
Free kick taken by Bradley Guzan.
Dismissal Nascimento Ramires is sent off by the referee.
Free kick awarded for a foul by Nascimento Ramires on Gabriel Agbonlahor.
Foul by Gabriel Agbonlahor on Gary Cahill, free kick awarded. Petr Cech restarts play with the free kick.
Ashley Westwood restarts play with the free kick.
Booking John Terry receives a caution for unsporting behaviour.
Foul by John Terry on Yacouba Sylla, free kick awarded.
Unfair challenge on Gary Cahill by Christian Benteke results in a free kick. Free kick taken by Petr Cech.
Centre by Andreas Weimann, clearance by John Terry. Ashley Westwood takes a outswinging corner.
Outswinging corner taken by Juan Mata from the left by-line played to the near post, Yacouba Sylla makes a clearance.
Gary Cahill challenges Gabriel Agbonlahor unfairly and gives away a free kick. Free kick crossed right-footed by Ashley Westwood, clearance by Ashley Cole.
Shot by Frank Lampard. Blocked by Nathan Baker.
Petr Cech restarts play with the free kick.
Booking Caution for Christian Benteke.
Cesar Azpilicueta fouled by Christian Benteke, the ref awards a free kick.
Free kick awarded for an unfair challenge on Gabriel Agbonlahor by Nascimento Ramires. Bradley Guzan takes the free kick.
Free kick awarded for a foul by Demba Ba on Andreas Weimann. Bradley Guzan takes the direct free kick.
The ball is crossed by Juan Mata, Ashley Westwood manages to make a clearance.
Corner taken right-footed by Eden Hazard.
Free kick awarded for a foul by Gabriel Agbonlahor on Eden Hazard. Frank Lampard produces a shot on goal direct from the free kick, save by Bradley Guzan.
The ball is crossed by Joe Bennett, clearance by Gary Cahill. Inswinging corner taken by Ashley Westwood, Petr Cech makes a comfortable save.
Juan Mata takes a inswinging corner from the right by-line to the near post, Nathan Baker makes a clearance.
Cesar Azpilicueta fouled by Andreas Weimann, the ref awards a free kick. Juan Mata crosses the ball from the free kick left-footed from right wing, Fabian Delph manages to make a clearance.
Demba Ba takes a shot. Save made by Bradley Guzan.
The assistant referee flags for offside against Gabriel Agbonlahor. Gary Cahill restarts play with the free kick.
Eden Hazard delivers the ball, clearance made by Ron Vlaar.
Fabian Delph concedes a free kick for a foul on Nascimento Ramires. Juan Mata crosses the ball in from the free kick, Nathan Baker makes a clearance.
Effort from outside the penalty box by Fabian Delph goes wide left of the goal.
Free kick taken by Joe Bennett.
Booking Nascimento Ramires goes into the referee's book.
Unfair challenge on Christian Benteke by Nascimento Ramires results in a free kick.
Assist by Yacouba Sylla.
14:00 Goal scored
Goal! - Christian Benteke - A Villa 1 - 0 Chelsea Christian Benteke scores a goal from close range to the bottom left corner of the goal. Aston Villa 1-0 Chelsea.
Victor Moses is ruled offside. Bradley Guzan takes the indirect free kick.
The ball is crossed by Ashley Cole, Ron Vlaar makes a clearance.
Direct free kick taken by Gary Cahill.
Booking Nathan Baker is shown a yellow card for unsporting behaviour.
Unfair challenge on Juan Mata by Nathan Baker results in a free kick.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.