The Rockets have been blowing fourth quarter leads this season and the Thunder have been pulling out games in the closing minutes.
Before the loss, Oklahoma City had been 8-0 in games decided by seven or fewer points and 3-0 in games decided by one point.
"We knew it was going to come down to the wire just the way it was going," Martin said. "In the third quarter, they would make a run, then we would make a run, so that's what we've been practicing and I'm just glad it paid off tonight."
The Thunder trailed most of the game but rallied in the fourth quarter and took it down to the final second, when Kevin Durant missed a short jumper.
The loss snapped Oklahoma City's five-game road winning streak and extended its losing streak to 11 in a row at Toyota Center.
"It's just a great win," Rockets coach Rick Adelman said. "It was a very good team we played. They were going to attack and keep coming at us but we did enough to win and that's what we wanted. We wanted our guys to play hard for 48 minutes and that's what they did."
Battier scored 18 points and hit three of his 3-pointers in the third quarter to help the Rockets maintain the lead. Houston was 10 of 17 from 3-point range. Kyle Lowry scored 14 points and Luis Scola added 13.
Russell Westbrook led Oklahoma City with 23 points, including 10 in the third quarter when the Thunder rallied from a 50-42 halftime deficit for a brief 63-61 lead with 5:27 to go in the period. Westbrook also had 10 assists.
The Rockets held Durant, the NBA's leading scorer, to 18 points, well under his 28.1 average entering the game. Battier got the big assignment against Durant.
"That's a tough assignment chasing that guy around all over the place but I tried to tell Shane that he's been pretty much getting nothing but stand-still 3s," Adelman said.
The Rockets took a 77-71 lead into the fourth quarter.
Oklahoma City never led in the fourth but cut it to 99-98 with 30 seconds to play on a basket by Westbrook. Lowry missed a shot with 5 seconds left and Thabo Sefolosha got the rebound before Durant's final attempt.
"It felt great when it left my hand," Durant said. "It's very frustrating. It's tough for me that it came up short. I've only had one [game winning shot] in four years in this league. Every one of my shots felt good. It was just one of those nights."
The Thunder haven't won at Toyota Center since an 87-85 victory on Feb. 22, 2005.
Serge Ibaka scored 12 of Oklahoma City's first 14 points, but Scola had 11 points and Martin added eight in the first quarter, and the Rockets held a 33-25 lead at the end of the period.
"We battled back and no one on our team gave up and we had a shot to win," Thunder coach Scott Brooks said. "Kevin's shot was on line but just a little short. We had a chance to win down the stretch."
Houston stretched the lead to 37-25 to open the second quarter, its biggest lead of the first half. The Thunder cut it to eight in a cold shooting quarter for both teams, and the Rockets held a 50-42 lead at halftime.
Oklahoma City trailed Indiana by 14 points in the third quarter on Friday night. Durant scored 11 of his 25 points in the final two minutes and overtime to pull out the victory. ... Westbrook has recorded nine double-doubles this season. Ibaka had a game-high eight rebounds and three blocked shots. The Thunder is 7-2 with Ibaka in the starting lineup.