HOUSTON (AP) -- The Milwaukee Bucks are learning how to pull out the close ones.
Monta Ellis sank an off-balance 3-pointer just before the final buzzer to give the Milwaukee Bucks a 110-107 victory over the Houston Rockets on Wednesday night.
Ellis scored 27 points and handed out 13 assists, Ersan Ilyasova added 20 points and 10 rebounds, and the Bucks won in Houston for the second straight season.
Milwaukee went down to the wire again after beating Dallas 95-90 on Tuesday and losing the previous three games by no more than three points. The Bucks and Rockets were tied 105-all when Larry Sanders tipped in Ellis' miss. James Harden tied it again on a driving layup with 35 seconds left.
Ellis rebounded Ilyasova's miss with 23 seconds left, giving the Bucks one last chance to win it in regulation. Ellis then took a pass from Brandon Jennings and threw up the game-winner off one foot. The ball rattled around the rim before dropping in, and by then, Ellis was running to the locker room.
''I just threw it up,'' Ellis said. ''The buzzer went off when it was rolling around the rim. Wasn't any need for me to come back out.''
The referees reviewed the shot and confirmed that it beat the buzzer. Jennings thought he delivered the pass too late for Ellis to get it off in time.
''But I'm kind of glad I made my move early,'' Jennings said. ''I didn't have anything, so I just kicked it out to him and he hit a one-legged 3-point shot for the win.''
James Harden scored 25 points, Chandler Parsons added 20 and Omer Asik grabbed a career-high 22 rebounds for Houston, which led by 17 points in the first quarter.
''It was a bad loss,'' Parsons said. ''There's no way around it. There is no way we should have lost that game.''
Mike Dunleavy had 16 points and new acquisition J.J. Redick added 14 for Milwaukee. Dunleavy thinks the Bucks learned from the late-game mistakes they made in the close losses over the past week.
''It kind of wakes you up,'' Dunleavy said. ''Sometimes, you can feel bad for yourself, bad for the team for a little bit. But eventually you come around on it, and say, 'All right, enough of this, we've got to get wins.'''
Jeremy Lin had 10 points and seven assists and Donatas Motiejunas scored 13 in his first start for Houston.
The Rockets made 12 of their first 13 shots and Lin had one of the early highlights, spinning a behind-the-back pass to Parsons for an easy dunk. Houston had 10 assists on its first 12 baskets, but after Asik finished an alley-oop from Parsons with a dunk, Houston went scoreless for almost three minutes.
''We just didn't have the same spacing, pace, that we had in the beginning,'' Lin said.
Jennings hit consecutive 3s and Dunleavy scored on three layups as Milwaukee mounted a 21-6 run to cut the deficit to two. It was close the rest of the way, and the lead changed hands 13 times in all until the Bucks made more plays down the stretch to win it.
''We're just getting stops and we're just countering on the offensive end,'' Jennings said of the late-game execution. ''We're just getting easier buckets and we're taking our time more.''
Harden played with a wrap on his left knee after he bumped into Ellis in the first half. Ellis scored seven points early in the third quarter to help Milwaukee build a seven-point lead. The Rockets quickly rallied, and Asik completed a three-point play to put Houston ahead 70-68 with five minutes left in the third quarter.
Dunleavy twisted his right ankle in the last minute of the third quarter and hobbled to the locker room. He returned with just under 10 minutes left in the game and the Rockets leading 88-84.
Houston continued to misfire from 3-point range early in the final quarter and Redick's 3-pointer near the six-minute mark put Milwaukee up 99-96. Houston went 7 for 23 from 3-point range, but blamed this loss on its poor defense at the end. The Bucks outscored the Rockets 11-2 over the final three minutes.
''Defense was not very good tonight,'' Parsons said. ''Bad game overall.''
NOTES: Bucks C Ekpe Udoh sprained his right ankle in the first quarter and did not return. ... Ellis had six steals and leads the NBA with eight games this season with at least five. ... Rookie Thomas Robinson, acquired in a trade with Sacramento last week, had a basket, a rebound, an assist and three fouls in his Houston debut. ... Asik has 26 double-doubles and 39 games with double-digit rebounds this season.