DALLAS — Coughing and wheezing, his temperature spiking to 101, worn out from hardly sleeping the night before, Dirk Nowitzki went through three miserable quarters in Game 4 of the NBA finals.

Yet the fourth quarter was his time to shine. Again.

And now the Dallas Mavericks and Miami Heat are starting over in the NBA finals, this best-of-7 series reduced to a best-of-three.

Nowitzki fought through a sinus infection and everything else that ailed him and his team to power a 21-9 run over the final 10:12, lifting the Mavericks to a memorable 86-83 victory Tuesday night. He scored 10 of his 21 points — including a driving right-handed layup that spun in off the backboard with 14.4 seconds left — and grabbed five of his 11 rebounds in the final period as Dallas pulled off its second stunning finish this series.

“Just battle it out,” Nowitzki said, sniffing throughout his postgame interview with his warm-up jacket zipped all the way up, still in his uniform instead of changing into street clothes like the NBA prefers. “This is the finals. You have to go out there and compete and try your best for your team. So that’s what I did.”

The Mavs avoided going down 3-1, a deficit no team has ever overcome in the finals, and guaranteed the series will return to Miami for a Game 6 on Sunday night.

“There’s no long term,” Nowitzki said. “I’ll be all right on Thursday. … Hopefully I’ll get some sleep tonight, take some meds and be ready to go on Thursday.”

Nowitzki wasn’t as dominant as Michael Jordan when he scored 38 points despite a 103-degree fever in Game 5 of the 1997 finals — but it was that kind of performance down the stretch. If the Mavericks wind up winning their first championship, this performance will go down in NBA lore, topping his effort in Game 2, when he bounced back from a torn tendon in the tip of his left middle finger to score the final nine points in Dallas’ 22-5 rally, including two left-handed layups.

By comparison, consider how meek a healthy LeBron James played Tuesday.

James scored only eight points, ending a double-figure scoring streak of 433 consecutive games, regular season and postseason. It was the first time in 90 playoff games that he scored such few points.

He made only 3 of 11 shots — a tip-in, a 15-foot jumper and a breakaway dunk. Not only did he not score in the fourth quarter, he took only one shot while playing all 12 minutes.

“I’ve got to do a better job of being more assertive offensively,” said James, who nonetheless contributed nine rebounds and seven assists. “I’m confident in my ability. It’s just about going out there and knocking them down.”

Dwyane Wade led Miami with 32 points, but missed a free throw with 30.1 seconds left and fumbled an inbounds pass with 6.7 seconds left. He knocked the ball back to Mike Miller for a potential tying 3-pointer, but it wasn’t even close to hitting the rim. Fans jumped to their feet and began roaring as soon as they could tell the ball was off-target.

The illness hit Monday night. After struggling to get any rest, he showed up for shootaround but hardly did anything.

His condition was kept a secret, and he helped keep it that way by hitting his first three shots. Then he missed 10 of 11 and it was obvious something was wrong. The biggest giveaway: he also missed a free throw for the first time since Game 4 of the conference finals.

Mavs coach Rick Carlisle tried resting Nowitzki as much as he could. During timeouts, he stayed in his chair as long as possible, trying to conserve every ounce of energy.

“You’ve got a guy that’s 7 foot, there’s a different kind of toll it takes on your body when you’re sick,” Carlisle said. “Everyone could tell looking at him that he labored.”

This series is now more fascinating than ever.

After the last two games were decided by two points, the first time that happened in the finals since 1998, this one was decided by three. In many ways, it was the best one yet because of how tight it was throughout.

The Heat seemed to have taken control when they led 74-65, their biggest lead of the night.

But Dallas went to a zone and Miami struggled.

Jason Terry — who kick-started that comeback with six straight points — made consecutive baskets, and the surge was on. Terry ended up capping it with two free throws with 6.7 seconds left that forced Miami to need a 3-pointer.

DeShawn Stevenson, who moved to the bench so J.J. Barea could join the starting lineup, scored 11 points for Dallas.

Bosh scored 24 points for Miami, but the Heat got little beyond its three superstars. Miller scored six points, Mario Chalmers had five and Haslem and Joel Anthony each scored four points.

It was an electric night from the start, with 20,430 fans again clad in their blue “The Time Is Now” giveaway T-shirts standing and screaming from the time Kelly Clarkson finished the national anthem.

The Mavs made half their shots in the first quarter, but gave up so many offensive rebounds — nine in the first 10 minutes, matching Miami’s total for Game 3 — that the Heat tied it after one period despite shooting only 29 percent.

Miami got going in the second quarter, putting together a 12-2 spurt. Soon after Haslem went to the bench with three fouls, Dallas went back ahead being a 9-0 run fueled by defense: a travel, a charge, a shot-clock violation and two turnovers. Then it was Wade’s turn.

He made two tough shots, then somehow got a shot to fall after being hit in the body and arms while driving to the rim. That three-point play started a 7-2 jag that left Miami up 47-45 at halftime.

Both teams sensed the game and series was on the line at the start of the third quarter. The action became more physical and both teams were up for the challenge, putting together six lead changes and five ties in the first 6:11.

In one flurry, Bosh hit a jumper with a man in his face, Barea darted to the rim and somehow got up a shot that then spun off the backboard and rim before falling, followed by Wade making a jumper over Marion as the shot clock was running out. Marion walked away shaking his head, smirking and saying, “I don’t know, I don’t know.” Then Marion came back and banked in a hook shot over James.