MIAMI -- The Golden State Warriors used a savvy play by a rookie and took advantage of a defensive breakdown to surprise the Miami Heat on Wednesday.

Draymond Green, a second-round draft pick out of Michigan State, made a layup with 0.9 seconds left to give the Warriors a 97-95 win over the Heat.

The Heat left him open under the basket as there was miscommunication between Ray Allen and Shane Battier.

"With the last shot, coach didn't point out who specifically was going to take the shot," Green said. "We were going to find out who was open and make the best play. Of course guys are going to go with Klay (Thompson) and Steph (Curry). I just happened to be wide open and (Jarrett Jack) found me."

Thompson tied a season high with 27 points to lead the Warriors, who have won five straight.

"We're on fire right now," Thompson said. "We're going to continue building on this. This is a special win. We haven't played the best competition the last few games but with the Miami Heat, we're showing people we're going to bring it every night. We have a chance to be special."

LeBron James led Miami with 31 points as he reached the 20-point mark for the 25th consecutive game, the longest current streak in the NBA.

After the game, James talked to Green to congratulate him.

"He played hard, it was great competition out there between me and him," James said. "I've also respected him especially in college, a big-time player and no one really gave him a shot, but you can tell he knows how to play the game.

"Any team that got him he will find a way to get minutes because he knows how to play the game and (Golden State) is a good fit for him. It was good to see him out there."

Jack dribbled the ball at the top of the key for the Warriors on the final possession as the clock ticked down before finding Green open underneath the basket.

"I was about to shoot it," Jack said. "... I was about to jump and in the corner of my eye I saw Draymond and I was able to make the pass and he converted the basket."

Green caught the pass in mid-air and made the basket as Battier was late in coverage.

"I think I showed too early," Battier said. "It was my responsibility. I got anxious. They made a nice play and burned for us our overanxious play out there, my overanxious play."

James' jumper from the baseline banged off the rim giving Golden State the win as Miami lost for just the second time in 12 home games and did not score in the final 3:18.

"You have to give Golden State a lot of credit for this road trip they are on right now, five straight," Heat coach Erik Spoelstra said. "It doesn't matter where you're doing that on the road, that's impressive. They took control of this game. They were playing more consistently with more force, more rhythm, execution, and they dug out a good win tonight."

David Lee scored 22 points and grabbed 13 rebounds, and Jack added 20 points off the bench for the Warriors.

Wednesday's victory over the NBA champs adds to their best start since 1991-92, as they improved to 15-7 and 9-4 on the road.

Golden State took a 77-74 lead into the fourth quarter after leading for most of the third.

After hitting a 3 to tie the game at 87, James gave the Heat their first lead since early in the third with a turnaround 18-footer with 6:39 left for an 89-87 advantage.

The teams played a one-possession game over the next four minutes before Lee knocked down a pair of free throws to tie the game at 95 with 1:54 left.

The score was still tied at 95 with under a minute remaining. Allen had a chance to give the Heat a lead with 46 seconds left. Lee followed by missing a driving layup. Battier's miss from the corner with 12 seconds left gave the Warriors an opportunity in the closing seconds.

"Ray got two clean looks, Shane got a clean look, Chris had some daylight on his roll to the rim, for the most part our execution going down the stretch we've had a lot of those games where that ball is going in and it changes your perspective," Spoelstra said.

The Heat received a scare in the second quarter when Lee sent James to the floor with a flagrant foul sending James to the floor on his back.

James popped up quickly, but spent the next couple of minutes stretching out his right shoulder before knocking down the free throw and hitting a shot on the ensuing possession for a 47-43 lead.

"I'll be all right," said James, who had an ice pack on his shoulder after the game. "It will be sore tomorrow, but I'll be ready by Saturday. That's all that matters."

Moments later, Dwyane Wade was poked in the eye by Thompson while trying to fight through a screen. With Wade's head down, Chris Bosh ran into Wade, knocking him to a floor. After staying down on the floor, Wade eventually got to his feet and went to the locker room holding the back of his neck with 3:11 left in the half.

"Right now it's fine," Wade said. "Hopefully it doesn't stiffen up on me tonight."

Thompson helped the Warriors take a 53-52 lead into halftime by scoring 21 points including five 3-pointers. Thompson scored 14 points in the second quarter, including 11 in a four-minute span.

Wade returned for the second half and opened the scoring with a dunk.

Both teams got off to a good start offensively, but it was defensive efforts by both teams that sparked the first highlight of the game.

After Stephen Curry picked off a pass by James, Wade returned the favor deflecting Curry's pass and ran toward the sideline saving the ball with an around-the-back pass to Mario Chalmers. Chalmers then found James, who tipped a pass to Wade for a layup and a 23-22 lead.

"We played against two guys (James and Wade) that will go down as all-time greats," Warriors coach Mark Jackson said. "For us to grind out a victory against the champs, it's special."

Game notes

Thompson has made at least five 3-pointers in three of his past five games. ... Prior to the game, Warriors coach Mark Jackson said he believes Wade is the third-best shooting guard in NBA history behind Michael Jordan and Kobe Bryant. "I see a guy I love as a basketball fan," Jackson said of Wade. ... Curry had his career-best streak of eight consecutive games with at least 20 points snapped as he scored nine points.