It took a lot to overshadow the first NBA three-pointer by Ben Simmons and a potential dust-up involving Joel Embiid, but a madcap 76ers comeback led by Mike Scott’s long-range shooting took center stage during a wild night in South Philly.

Trailing by 17 points with less than four minutes left in the third quarter, the Sixers roared back for a 109-104 win over the New York Knicks at a charged-up Wells Fargo Center on Wednesday night.

Embiid had 23 points and 12 rebounds. Simmons added 18 points and a season-high 13 assists. Scott finished with 12 points off the bench, hitting 4 of 6 three-pointers.

“We had to pick it up, and we made it hard on ourselves, and the energy wasn’t there, the physicality just wasn’t there,” Simmons said about getting down by 17. “We had to pick it up and know we had put ourselves in a hole.”

The Knicks trailed, 96-95, with two minutes left, after Julius Randle hit one of two free throws.

The Sixers then went on a 6-0 run, getting threes from Scott and Embiid, to make it 102-95 with 51.2 seconds left.

The Knicks cut the lead to 107-104 on a Marcus Morris three with 2.1 seconds remaining, but Embiid hit two free throws for the final scoring.

Scott was a key off the bench with his three-point shooting.

“My teammates were finding me, and I had confidence and was able to do what I do,” Scott said.

The Sixers are 9-5 and have won two in a row. They are 5-0 at home. New York fell to 4-11.

When Knicks rookie RJ Barrett made a follow dunk, it increased New York’s lead to 77-60 with 4:15 left in the third quarter, and the Sixers looked to be in big trouble.

More than a few boos could be heard, but then the Sixers flipped the switch, began pressuring the Knicks, causing turnovers while hitting big threes.

The Sixers ended the quarter on a 14-2 run and trailed just 79-74 entering the fourth quarter.

In that run, the Sixers got threes from Scott, Al Horford, and James Ennis.

The Sixers continued the momentum with a 35-25 fourth quarter.

Fireworks almost erupted in the first half, after Tobias Harris made a turnaround 20-footer to cut the Knicks lead to 49-47 with 1:43 left.

On the play, the Morris, boxed out Embiid and threw him to the ground. Tempers flared, but order was quickly restored without incident.

A double technical foul was assessed against Morris and Embiid. Morris, a Philadelphia native who wasn’t very popular in his home town at that moment, was also assessed a Flagrant One foul.

Unlike a previous incident when Embiid received a two-game suspension for an altercation with Minnesota’s Karl-Anthony Towns, the Sixers’ center kept his cool.

“I just got thrown on the ground, and I literally don’t know why I got the technical foul," said Embiid, who added that he will play the next two home games, Friday against San Antonio and Saturday against Miami.

Morris said: “He was too big to be flopping. He was flopping and grabbing. I am not the one who is going to take that, he knows that.”

Simmons hit his three-pointer with 8:20 left in the first quarter. It was his first three-point attempt of the season. Before that, he was 0 for 17 in the regular season and 0 for 1 in the playoffs.

Simmons took a bounce pass from Furkan Korkmaz and from the right corner calmly sank the 24-footer over Mitchell Robinson, who offered little resistance.

The sellout crowd cheered loudly.

“It feels good -- you put work into something and it pays off,” Simmons said.

Korkmaz was starting in place of Josh Richardson, who was out with right hip flexor tightness.