Amir Johnson scored the winning basket with seven seconds left, and the Toronto Raptors clinched their first playoff berth in six seasons by beating the Boston Celtics 105-103 on Friday night.

DeMar DeRozan scored 30 points as the Raptors won for the 18th time in 24 home games. Terrence Ross had 17 points, Greivis Vasquez scored 15 and Jonas Valanciunas finished with 13.

The Atlantic Division-leading Raptors last reached the playoffs in 2007-08, losing in five games to Orlando in the first round. This is their sixth playoff berth in 19 seasons.

Jerryd Bayless scored 14 of his 20 points in the fourth quarter, but it wasn’t enough for Boston, which has dropped three straight and eight of nine. Jeff Green scored 16 points, while Jared Sullinger, Rajon Rondo and Avery Bradley each had 11.

The Celtics dropped to 8-27 on the road.

Toronto led 95-86 on back-to-back jump shots by DeRozan with 8:04 remaining, but Chris Johnson scored four points as Boston replied with an 8-0 run, causing the Raptors to call timeout.

Bayless put Boston in front with a jumper at 4:52, and then followed a layup by Lowry with a 3, giving the Celtics a 99-97 edge with 3:56 left. Bayless went 8 for 13 from the field against his former team.

Olynyk pushed the lead to four with a layup, but Vasquez fed Lowry for a driving layup, and then made a pair of free throws to tie it at 101 with 1:14 remaining.

After a Boston timeout, Lowry rebounded Green’s missed shot, but Green hustled back to deny DeRozan a layup. Toronto kept the ball, and DeRozan put the Raptors ahead with a fadeaway jumper.

Rondo tied it for the eighth time with a layup, and Toronto called timeout, advancing the ball to midcourt. Lowry couldn’t convert a driving layup, but Johnson grabbed the rebound and banked it home to put the Raptors up by two.

Rondo inbounded the ball to Sullinger with three seconds left, but his shot bounced off the backboard as the buzzer sounded, sending the sellout crowd of 19,800 into joyous celebration.

The Raptors started the game in a funk, missing five of their first six shot attempts, but responded by hitting 10 of their next 12. Valanciunas scored 10 points in the first and Ross had nine as Toronto led 32-26 after one.

Lowry appeared to injure his right ankle when he got tangled up with Bradley after missing a 3 with just over three minutes to go in the second. Lowry was helped off the court but managed to walk to the locker room for treatment.

Green scored seven points in the second and Sullinger had six, but Toronto’s Tyler Hansbrough scored a layup with less than a second remaining to give the Raptors a 56-53 lead at halftime.

Lowry had his ankle re-taped during the break and started the second half for Toronto, but DeRozan was the star of the third quarter. He scored 12 points as the Raptors took an 85-73 lead into the fourth.

NOTES: Green, who was bothered by a stiff neck in Wednesday’s loss to Toronto, started for the Celtics. Coach Brad Stevens said Green was feeling “much better.” … Toronto coach Dwane Casey said F Patrick Patterson, out since Mar. 7 with a sore right elbow, could return Sunday or Monday. “He’s still sore but he’s making great progress,” Casey said. … Lowry played in his 499th career game.

Join our Newsletter for the latest news right to your inbox