Among life’s certainties, Dallas beating Sacramento at American Airlines Center isn’t as inevitable as death and taxes, but it’s the closest thing the Mavericks have.

On Friday night, though, the Mavericks had to rally from a 14-point third quarter deficit to pull out a 107-103 victory over the Kings.

It was the Mavericks’ 19th straight home victory over the Kings, the longest such streak in franchise history. But on this night the Mavericks (27-21) needed 34 points from Dirk Nowitzki and an 11-point fourth quarter from Monta Ellis to overcome Sacramento, which got 35 points from Rudy Gay.

“We had to grind it out,” said Nowitzki, who followed Wednesday’s 38-point, 17-rebound game against Houston with an 11-of-19 shooting performance Friday, a day after being named to his 12th NBA All-Star team. “We really had to dig deep there and get some stops in the fourth quarter.”

The Kings entered the game with a five-game losing streak, the Western Conference’s worst record (now 15-31), and were playing their fifth straight game without injured center DeMarcus Cousins.

Still, the Mavericks needed a 27-9 run to retake the lead at 89-87 on a pair of Nowitzki free throws with 6:54 left. They needed near-flawless execution, committing zero second-half turnovers and only four all game.

And they needed a huge fourth-quarter scoring lift from Ellis, who in his last three games had scored only 16, 11 and six points. Midway through Friday’s third quarter had only four points.

Two days after coach Rick Carlisle criticized the Mavericks for getting “blown by” numerous times against the Rockets, Ellis helped hold Kings shooting guard Marcus Thornton to nine points.

Ellis committed no turnovers Friday. To Carlisle, the fact that Ellis erupted offensively late to finish with 20 points was merely icing on “probably his best all-around game of the season.”

“Tonight, his defense was spectacular,” Carlisle added. “It was one of those nights when he easily could have gotten frustrated, but he didn’t. He just kept playing the whole game and it came around.”

Ellis’ late run included 7-of-7 free-throw shooting in the fourth quarter, a 3-point play with 12.4 seconds left that gave Dallas a 105-100 lead and two clinching free-throws with 4.6 seconds left after Sacramento had pulled within two.

“Hopefully we can have more [of these games] consistently,” Ellis said of his performance. “I felt good, more aggressive. I picked my spots, looked to find open guys, and on the defensive end was just more in the help position.”

The Kings opened the third quarter with a 17-3 run, giving them a 66-57 lead and quieting the crowd. Sacramento’s lead grew to 78-64 with 3:44 left in the third quarter.

That is when Nowitzki and Jose Calderon (14 points) began leading the run that gradually got Dallas back into the game. After missing their first 14 3-point attempts, the Mavericks finally got a successful trey from Nowitzki with 8:15 left, pulling them within two at 87-85.

That was roughly when Memphis wrapped up a 94-90 victory at Minnesota, at least temporarily pulling the Grizzlies percentage points ahead of Dallas for eighth place in the Western Conference playoff race. Even though it was only a late-January game, the Mavericks could ill afford a home loss to the last-place team in the West.

“You’d have to be blind not to see the West is always a logjam,” said Mavericks guard Devin Harris, whose seven points complemented the performance of another reserve, Brandan Wright, who had 10 points and 10 rebounds. “We definitely know. And Coach lets us know that certain games are important and teams are right there with us, so we’re aware of it.