It was a battle of attrition; two aging teams with hopes of one more title run slugging it out. Neither impressive. Neither polished.

Desperately trying to get out of the “win one, lose one” pattern that has marked the first quarter of their season, the Celtics had just a bit more left in an exhausting affair with the Mavericks, getting a gritty win despite wasting numerous chances to end the game much earlier.

After a rather rough night being guarded by Dahntay Jones and Derek Fisher, Paul Pierce came back in double overtime to score 8 points, including five free throws, and the Celtics outlasted Dallas, 117-115, Wednesday night at TD Garden.

Pierce opened the second OT with a 3-pointer and the Celtics never trailed again. Following an O.J. Mayo layup, Rajon Rondo responded with a layup with 35.5 seconds left and then rebounded a Darren Collison miss as the Celtics made seven free throws to seal their second consecutive win.

The Celtics are a season-best three games over .500.
That’s a small accomplishment, but with as much transition and inconsistency as they’ve had this season, the Celtics will gladly accept the momentum boost.

“We didn’t want to let this one get away,” said Pierce, who scored 34 points on 11-for-25 shooting. “Especially with a huge road trip coming up, this is a big win for us. Dallas is one of those sneaky teams, you don’t really know what to expect from them night in and night out. For us to go double overtime and show some resiliency, it was great.”

The minutes played were ringing up like the cash meter at a gas station. Pierce played 44 minutes, Rondo 53, Jason Terry nearly 48, and Kevin Garnett, whom coach Doc Rivers likes to keep under 30, logged 40.

“I probably would have been a lot more tired if we had lost,” Garnett said. “It was a good game, though. Both sides showed some resiliency. It came down to execution. They hit some big shots to get back into the game. We have this thing in practice where you go defense and then you play offense. I figured if I was in there to play regular minutes then I earned the right to play overtime. Let me play. I know how to gauge myself.”

Garnett finished with 16 points and Rondo added 16 points, 15 assists, and 9 rebounds. Mayo led Dallas with 24 points but had to work feverishly to get free and committed nine of Dallas’s 27 turnovers. Six were committed in the two overtimes.

In the fourth quarter, the Celtics’ offense began sputtering as Pierce had a tough time against the undersized Fisher as the Mavericks went extra small. Coach Rick Carlisle even implemented a zone, forcing Garnett and Pierce to shoot over two or three defenders.

And slowly, the Mavericks began cutting the Celtics advantage. A Vince Carter layup followed by a Jones runner sliced the deficit to 86-85. And old Lakers nemesis Fisher scored on a layup to make it 90-87, then gave the Mavericks their first lead with a crowd-quieting 3-pointer for a 95-94 edge with 1:47 left.

Pierce came back with a jumper at the 1:30 mark and Mayo tied the game with a free throw. The teams spent the last 52 seconds of regulation botching chances to win. Mayo’s turnover gave the Celtics the ball with 8.9 seconds left but Rondo held on to the ball too long and Fisher got a hand on his shot attempt.

The transition game was the key in the third quarter, as Rondo constantly pushed the ball and the result was easy baskets. Brandon Bass made a pair of hooks, including a dunk on Chris Kaman, and Chris Wilcox followed with a layup for a 68-54 lead.

Nothing was comfortable, however, for the Celtics. Susceptible to dribble penetration all season, they allowed Collison, a newcomer from Indiana, to spark a 16-6 run, as he was diving into the paint for layups. He ended the quarter scoring Dallas’s final 6 points to slice a 14-point Celtics lead to 6. Collison finished with 20 points off the bench.

Poor shooting stopped the Celtics from taking control in the second quarter as they led by as many as 10 but watched that sliced to 5 at the break. Besides Pierce, who was 4 for 5 for 11 points, the Celtics were 3 for 14 for 10 points. The rest of the starters were a combined 0 for 6.

The fortunate part was the Celtics’ rejuvenated defense clogged up the paint and also checked the perimeter, forcing the Mavericks into one-on-one play. Mayo, Dallas’s leading scorer entering the game at 20.8 points per, was limited to 6 first-half points, just 2 in the second quarter.

The Celtics used a Pierce-fueled 5-0 run to take a 45-35 lead with three minutes left in the period, but the Mavericks stormed back with a 7-2 run as Collison made a couple of drives to reduce the margin to 48-43.

The early storyline was Terry facing his old club, but that soon was overshadowed by the Celtics’ desperate need to earn consecutive wins.

They never trailed in the first half and actually led by as many as 10 but couldn’t capitalize on opportunities to build on the lead.

And their inability to create distance meant they were forced to go extras to get a key victory.

“You know, I didn’t like our shots that we got down the stretch, but overall we had a lot of good shots and they weren’t going in,” Rivers said. “So we won a game where a team shot 51 percent and we shot 43 percent. That wasn’t happening to us earlier in the year if you remember. We lost a couple of games where it was the exact opposite.”

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.

Thanks & Welcome to Globe.com

You now have unlimited access for the next two weeks.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.