With their playoff lives hanging in the balance, the Dallas Mavericks showed some true grit Wednesday night when they outslugged the Houston Rockets 112-108 at American Airlines Center.

In a game that took on a very physical tone, the Mavericks finally fought back at the most opportune time and won a game against a quality team to remain within shouting distance of the playoff race.

The win helped the Mavs (27-33) atone for Sunday’s 136-103 loss to the Rockets in Houston. That lopsided loss was the motivation the Mavs needed to exact revenge and get within 4 1/2 games of the eighth-place Utah Jazz in the Western Conference standings.

O.J. Mayo filled up the stat sheet for the Mavs, finishing with 13 points, a career-high 12 assists, six rebounds and no turnovers.

“It’s his best game of the year — not even close,’’ coach Rick Carlisle said. “He played great defensively, his awareness was tremendous, and offensively he made the right play virtually every time.’’

Mayo, who scored seven consecutive Mavs points after the Rockets had inched within 100-99, said he was just trying to get his teammates involved in the game.

“It pretty much just came in the flow of the game,’’ Mayo said of his assists. “I just wanted to make the simple play every time down the court.’’