Updated

Tyson Chandler matched his season high with 21 points and had 15 rebounds, reserve J.J. Barea added 19 points and the Dallas Mavericks hung on after wasting most of a 25-point first-half lead in a 111-106 victory over the Houston Rockets on Thursday night.

Dirk Nowitzki had 18 points and Jason Terry contributed 15 points for Dallas. The Mavericks have won four of five following a six-game losing streak.

Luis Scola led Houston with 30 points, and Kevin Martin had 27.

Houston pulled to 104-103 with 51.8 seconds left when Scola completed a 12-2 run with a tip-in.

But Barea hit a 13-footer with 32.9 seconds to go, and Nowitzki converted one of two free throws with 23.1 seconds left to make it 107-103.

Aaron Brooks missed a layup with 17.8 seconds remaining, and Terry made two free throws with 14.3 seconds left for a 109-103 lead, icing the victory.

Houston put together a 26-6 surge to narrow the huge first-half deficit to 77-75 with 4:06 left in the third quarter. Scola had 10 points and Shane Battier hit a pair of 3-pointers during the spurt.

The Mavs recovered with a 10-3 run over the final 3 minutes of the quarter, capped by Barea's twisting layup with 3.9 seconds left, for an 88-81 advantage.

Dallas used a 17-2 run to roll to a 28-10 lead. The Rockets were a step slow early after beating the Clippers on Wednesday night. The Mavericks had been off since beating the Clippers on Tuesday night.

The Mavs carried a 33-15 advantage into the second quarter, taking advantage of Houston's 6-for-21 shooting (28.6 percent) in the opening quarter. The Mavericks were in front at halftime, 64-47. Chandler had 14 points and eight rebounds, and Nowitzki added 13 points in the half.

Dallas had its largest halftime edge and best scoring half of the season.

NOTES: The Mavericks pulled out a 101-91 victory over the Rockets on Nov. 29, the only other meeting between the teams this season. But Dallas had No. 3 scorer Caron Butler in that game. Butler is out for the season with a torn tendon in his right knee. ... Recently signed F Peja Stojakovic isn't quite ready to join the Mavericks' rotation. Stojakovic has been practicing with his new teammates and has been shooting after practice with Nowitzki, but coach Rick Carlisle said before the game that Stojakovic still needs time to round into basketball shape. Stojakovic hasn't played since November for the Toronto Raptors. ... Houston's 15-point first quarter matched its lowest output of the season for the opening 12 minutes. ... Dallas didn't have a starter voted to the Western Conference All-Stars announced Thursday, although Nowitzki will most likely get a berth as a reserve. Mavericks owner Mark Cuban said Thursday that Chandler also deserves to be on a team that projects to lack true centers. ... Dallas is 16-5 in its last 21 games with Houston.