The New Orleans Pelicans played the Dallas Mavericks closely twice earlier this season, only to fall short at the end.

Anthony Davis, the Pelicans power forward who soon will make his first All-Star Game start, made sure that didn’t happen again.

Making plays on both ends of the court in an inspiring effort over the final 57 seconds, Davis helped the Pelicans pull out a 109-106 victory on Sunday at the Smoothie King Center against a team that has tormented them for two seasons.

The win ended a nine-game winning streak by the Mavericks (30-15) against New Orleans (23-21) that dated to Jan. 5, 2013. In the first game of a six-game homestand, the victory also gave the Pelicans their first three-game winning streak of the season.

“It’s huge for us,” Davis said. “Everybody contributed, played with their hearts. It’s just a big team win — (Southwest Division) opponent, team that’s in our conference, and a team that’s up there. We’re trying to knock some of those teams down.”

Davis scored a team-high 28 points and added 10 rebounds, five steals and a block. He sank two free throws with 12.3 seconds left that gave New Orleans the lead for good, at 107-106, after Dallas center Tyson Chandler was called for a foul with New Orleans inbounding the ball.

Then, with 9.4 seconds left and the Mavericks inbounding the ball at halfcourt, he preserved the victory by stealing a pass intended for Dallas power forward Dirk Nowitzki.

Davis credited Tyreke Evans, who had 24 points and 12 assists. Evans was guarding the inbound passer, Chandler Parsons, but switched on to Monta Ellis, to whom the Mavericks were trying to get the ball.

“Coach (Monty Williams) made a great call,” Davis said. “He said, ‘Whoever is on the ball, take Monta out. Don’t let him get it.’ The next option was Dirk.”

Parsons tried to throw the ball over Davis’ head; he deflected it, came up with the loose ball and then called a timeout. After the breather, Davis received the inbound pass, was fouled and sank two clinching free throws. Chants of “MVP! MVP!” rang out as the Pelicans moved two games over .500 for the first time since Nov. 22, when they were 7-5.

The win moved the Pelicans into sole possession of the ninth spot in the race for one of the Western Conference’s eight playoff positions; the Oklahoma City Thunder, who had been tied with the Pelicans, lost at Cleveland on Sunday. The Pelicans also gained a game on the Phoenix Suns for the eighth spot; they lost to the Los Angeles Clippers at home.

Dallas coach Rick Carlisle said the Pelicans, particularly Davis, made the plays at the end to get the victory. But he said New Orleans had help, particularly on the foul called on Chandler.

“We thought we played aggressively, and (the official) blew the whistle,” Carlisle said. “You never want to see a call made like that, but they made it. You have to play through it.”

Asked whether Davis’ play down the stretch was the difference, Carlisle said, “The difference in the game was the whistles, really — calls that were made and calls that weren’t made. Sometimes that’s how it goes. But they made plays.”

The Pelicans also received a huge lift from their bench. In the two losses to Dallas this season, their bench was outscored 71-41, including 36-14 in a 109-104 setback Nov. 1 at the Smoothie King Center. This time, the Pelicans’ reserves outscored the Mavericks’ group 38-19. Ryan Anderson, who returned after missing Friday’s game at Minnesota with inflammation in his ankles, scored 18, all in the first half. Quincy Pondexter added 14.

Ellis led Dallas with 36 points and was up to his usual late-game antics. He blew past Davis for a layup and a 104-103 lead with 34.5 seconds left, then drove on Pondexter with 12.3 showing for Dallas’ final lead at 106-105. Next came the play in which Chandler fouled Davis before the ball was inbounded.

Ellis had a desperation shot in the final seconds, but it clanged off the rim, and Davis clutched the rebound.

The Pelicans host the Philadelphia 76ers at 7 p.m. Monday at the Smoothie King Center. The 76ers (8-36) beat the Pelicans 96-81 on Jan. 16 in Philadelphia, perhaps New Orleans’ worst loss of the season.