LOS ANGELES — After just 12 games together, Anthony Davis and LeBron James already know how to share the workload in their formidable partnership.

Davis struggled to find his offensive game against Sacramento, so James did most of the heavy lifting with 29 points and 11 assists.

But when the Lakers needed a big defensive play at the buzzer, Davis got both hands around it.

James hit two free throws with 5.5 seconds to play, and Davis blocked Harrison Barnes’ driving shot at the buzzer with two hands to end Los Angeles’ 99-97 victory over former coach Luke Walton and the Kings on Friday night.

Davis had only 17 points in his second lowest-scoring performance for the Lakers, but he came through late to seal their 10th win in 11 games. Davis had little rhythm with the ball in his hands, so James consciously took the lead on offense while Davis waited for the chance to back him up.

“It definitely increases my mindset defensively,” said Davis, who sat out the previous game to rest his sore right shoulder. “When the shot’s not falling, I try to do the other things to help the team win.”

Kentavious Caldwell-Pope scored 12 of his 16 points in the fourth quarter of the Western Conference-leading Lakers’ third straight win despite a spirited effort by the undermanned Kings.

The Lakers led 95-90 with three minutes left after Caldwell-Pope’s third 3-pointer, but Bogdan Bogdanović scored five straight points to tie it. James hit a layup with 1:50 left, but Bogdanović eventually replied with a tying layup with 22 seconds to play.

Barnes fouled James on the perimeter, and the shaky free-throw shooter smoothly hit both of his shots. Barnes then tried to drive for a tying shot, but Davis got his fourth block of the night in two-handed style while the Kings hoped in vain for a foul call on moderate contact.

“We played it to perfection,” James said. “When you have a shot-blocker the caliber of (Davis) protecting the rim, that just makes it that much tougher on Harrison.”

Buddy Hield had 21 points and eight rebounds, and Bogdanović added 18 points for the Kings in the LA return of Walton, who was fired by the Lakers last April after presiding over three consecutive losing seasons.

“One call changed the whole game, you know,” said Hield, who appeared to be furious with the no-call at the buzzer. “Could have gone either way. It be like that sometimes when the home team is favored all the time, especially when you’re in LA. … We’ve got something good going here, but this game, we should have won. I think we just got it stolen away from us.”

Sacramento nearly pulled off the upset despite playing without De’Aaron Fox, who missed his second straight game with a sprained left ankle, and Trevor Ariza, who sat out with a sore groin.

“We had some open looks we didn’t knock down, but that is a big, talented team, and I thought our guys were light on numbers,” Walton said. “We had to put guys in that hadn’t played much at all, and everyone that checked in fought and competed.”

Walton’s pregame introduction was greeted with an indistinguishable mix of boos and cheers of “Luuuuuke” for the coach who took over the Lakers in 2016. The former Lakers forward’s teams posted three straight improved records, but his performance wasn’t rated highly by former Lakers boss Magic Johnson or by general manager Rob Pelinka, who fired Walton just five days after Magic’s surprise resignation last April.

“This is why this job is fun,” Walton said. “It’s fun, it’s stressful, it’s hard, but this is what you, as a competitor, you love to do. And to be back in your old building and playing against the team you used to coach and play for, it’s exciting.”