MIAMI -- Dion Waiters watched his 3-point try bounce off the rim, ricochet off the top of the backboard, then hit the rim again and somehow drop through the net.

It was a huge shot in the final moments, and a lucky one.

That's what it took to end Boston's 16-game winning streak.

Goran Dragic scored 27 points, Waiters had 26 with a pair of big 3-pointers in the final minutes and the Miami Heat held on to beat Boston 104-98 on Wednesday night and become the first team to beat the Celtics since Oct. 18.

"You can tell they were locked into this game," Celtics star Kyrie Irving said. "They wanted it and proved it."

Boston trailed by as many as 18, and was down by 14 midway through the fourth quarter. Rallies were a hallmark throughout Boston's winning streak -- the Comeback Celtics had overcome 18-point deficits against Oklahoma City and Charlotte, a 17-point hole against Golden State, a 16-pointer against Atlanta and rallied from 13 down to win in Dallas earlier this week.

They almost did it again.

A 13-0 run got Boston to 91-90 with 3:14 left, and that's when Waiters took over. The next six points were his -- first the 3-pointer that bounced three times before falling, then another one from the left corner when the words of Heat coach Erik Spoelstra were echoing in his head.

When Waiters drives and a bigger defender comes his way, he likes to go airborne for a pass or some sort of acrobatic layup. Spoelstra has tried to break him of that habit, and Waiters kept going all the way to the corner with the Celtics' Al Horford forced to cover him. Waiters created space, then let fly with a 3-pointer for a 97-90 lead.

"I knew I had what I wanted," Waiters said.

For a change, so did the Heat. An up-and-down start to the season is on an upswing again, and Spoelstra -- who put Miami through two training-camp-type practices Monday and Tuesday after a 25-point home loss Sunday to Indiana -- moved on quickly after the win.

"Our identity is to be tough and we haven't shown that consistently enough," Spoelstra said. "Pockets, here and there. It's that kind of effort to get a six-point win. Nothing is guaranteed, but that has to be what we embrace all the time. So, good. How about next game?"

Tyler Johnson scored 16 points for Miami, which shot 49 per cent and outrebounded the Celtics 48-37. Irving scored 23 points for Boston. Jayson Tatum added 18, and Jaylen Brown and Marcus Morris each had 14.

The Celtics started 0-2, and hadn't lost since. But coach Brad Stevens has insisted throughout that he hasn't spent any time thinking about the streak, keeping eyes instead on a bigger picture.

"Like I said, 16 straight is a little bit of a mirage," Stevens said.

TIP-INS

Celtics: Aron Baynes started for Morris, who wanted to test his problematic knee. Morris played 21 minutes off the bench. ... Boston turned Miami's first eight turnovers into exactly zero points. The Celtics wound up getting nine points off 16 Miami giveaways. ... Shane Larkin was shaken up briefly after taking a hard foul near the rim by Miami's Kelly Olynyk early in the fourth.

Heat: Olynyk tried to shoot one over the backboard with 7:26 left after being forced to the baseline on a dribble. The shot wasn't close. ... A weird quirk: The Heat have played on all six Wednesdays so far this season -- and play on the next four as well. They won't get a Wednesday off until Dec. 27. ... The Miami Hurricanes, the No. 2 team in both the AP Top 25 and the College Football Playoff rankings, were at the game.

STREAK ENDS

The 16-game winning streak ended tied for the fourth-longest in Celtics history. Boston won 19 in a row in the 2008-09 season, 18 straight in 1981-82 and 17 straight in 1959-60. The other 16-game run was in 1964-65. In NBA history, 21 streaks have lasted longer than 16 games.

WIN THE THIRD

Miami won the third quarter 25-22, which doesn't sound like much -- but was significant to the Heat. That three-point margin, somewhat unbelievably, is their fourth-best in a third quarter this season. Miami had been outscored 60-29 in its previous two third quarters.

UP NEXT

Celtics: Host Orlando on Friday night.

Heat: At Minnesota on Friday night.