CLEVELAND — The home crowd booed as James Harden walked from one side of the court to the other, upset that Isaac Okoro’s and Evan Mobley’s swarming defense had resulted in a foul in a two-point game with 16.8 seconds to play.

The 76ers’ newest star then stepped to the free-throw line and drained both shots — and then another two when the Cavaliers fouled on purpose less than three seconds of game time later — which sealed a 118-114 victory Wednesday night at Rocket Mortgage FieldHouse.

“If it becomes a free-throw shooting contest, I feel pretty confident with our team,” coach Doc Rivers said.

The Sixers (42-26) built a 17-point first-half lead, then needed to answer the Cavaliers’ second-half charge. Cleveland outscored the Sixers 31-13 in the third quarter to flip a 13-point deficit into a 90-85 lead, when Brandon Goodwin and Kevin Love hit back-to-back three-pointers to close the period.

Then, neither team created separation in the fourth until the final two minutes, when Tyrese Maxey buried a three-pointer with the shot clock winding down to give the Sixers a 110-106 lead.

“Tobias [Harris] threw it to me and I turned down [a shot],” Maxey said of that play. “I gave it back to Joel [Embiid] and I knew it was going to come back to me. I knew they were going to trap him and I knew he was going to pass the ball.

“He already told me if he didn’t trust me, then he wouldn’t pass it to me.”

The Cavaliers’ Caris LeVert answered with a layup, but Embiid followed with his own authoritative finish inside. Cleveland’s Darius Garland then hit two free throws to again get within one possession at 112-110 before Harden’s decisive free throws. LeVert again made things interesting when he converted an and-one finish that cut the Sixers’ lead to 116-114 with 8.3 seconds to play, but he missed the ensuing free throw and Maxey grabbed the rebound and hit the free throws that completed the night’s scoring.

The Sixers got another monster outing from Embiid (35 points, 17 rebounds, 5 assists) on his 28th birthday, and efficient nights from Harris (19 points on 8-of-13 shooting, 6 rebounds, 3 assists) and Maxey (25 points on 9-of-15 shooting). Harden made just 5 of his 12 field-goal attempts in his ninth game with the Sixers but went 10-of-12 from the free-throw line to finish with 21 points and added 11 assists.

“We missed layups, we missed wide-open threes, but I loved how we played,” Rivers said of a night when the Sixers scored 30 points in the first quarter, 42 in the second and 33 in the fourth. “I loved how the ball moved and everybody was involved, and I told our guys you can see it coming offensively. ...

“Offensively, we didn’t have a lot of hiccups.”

For the third time in less than five weeks, the Sixers were a cut above an upstart Cavaliers team that could be their first-round playoff opponent. They will go for the 4-0 regular-season series sweep on April 3 in Cleveland.

Happy birthday, Mr. Embiid

Embiid collected the ball that had briefly been knocked away, turned and fired from deep as the shot clock expired.

Bang!

It was quite the birthday performance for the MVP contender, who did not look like a man who was questionable to play earlier in the day because of back soreness stemming from the hard fall he took Monday against Denver. When a reporter mentioned that Embiid had been on the injury report earlier in the day during the postgame news conference, Harden gave Embiid a bewildered look and said, “What?!”

Embiid made all six of his first-quarter shots, primarily on turnaround jumpers against a Cavaliers frontcourt that was overmatched without All-Star Jarrett Allen on the floor because of a broken finger. He had collected his 35th double-double of the season — and matched his season average in assists — by halftime.

“Just the discussion that we’ve been having the last few games, we needed to have better starts and be better focused offensively and defensively,” Embiid said. “Obviously we did that, but we’ve got to also be focused throughout a game [and] keep that same mindset.”

Embiid squashed the Cavaliers’ initial third-quarter rally when he followed a Lauri Markkanen dunk that cut the Sixers’ lead to 74-68 by collecting his own missed tip-in and converting through contact and while falling down for the three-point play, then taking a feed from Harden for a streaking one-handed dunk.

About midway through the fourth, Embiid drew contact on a jumper to tie the game at 98 and then drew a foul and sank both free throws to give the Sixers a two-point lead.

» READ MORE: The Sixers’ Joel Embiid will play against Cavaliers after being listed as questionable with back soreness

Bench still quiet — until late

Despite the balanced scoring effort from the Sixers’ starters, their bench was outscored 41-13. But that group made some key plays in the final period.

Stretch forward Georges Niang struggled from the floor for the second consecutive game (1-of-5), but hit a massive corner three-pointer to give the Sixers a 103-101 lead with less than five minutes to play and also collected a crucial offensive rebound and steal late in the game. Center DeAndre Jordan whiffed while trying to slam home an alley-oop dunk in the first half, but in the early fourth finished the slam from Harden to push the Sixers ahead 91-90.

The Sixers’ second unit went 2-of-9 from the floor in the first half, with the only makes coming on two Danny Green corner threes. Green was the Sixers’ first sub and played stints alongside fellow wing Matisse Thybulle against the Cavaliers’ bigger lineup, and played crunch-time minutes at the end of the first half while Thybulle sat with three fouls.

Shake Milton only played three first-half minutes and was minus-6 during that time. Isaiah Joe entered the game for the first time at the start of the fourth quarter and picked up two quick fouls in four minutes.

“It’s going to be different guys [playing each game],” Rivers said. “Nobody in the locker room is complaining about it. They understand it. They want to do whatever they can do to help the team win. ...

“We’ve got to make sure we find the right group. One night, it might be a defensive group where we’re just trying to hold the fort. One night, it may be an offensive group because the other team is scoring and we need scoring. That’s what we have with 14 games to just keep working on.”