The shorthanded Celtics ended the NBA’s longest active winning streak Wednesday night, knocking off the Eastern Conference-leading Pistons in a thriller at TD Garden.

Playing without injured starting center Neemias Queta for the first time this season, Boston rode big nights from Jaylen Brown (33 points, 10 rebounds, five assists, two steals, two blocks and Derrick White (27 points, seven rebounds, three steals, one block) to a 117-114 victory that snapped Detroit’s run of 13 consecutive wins.

“Great win,” Brown said. “It just tells us that any given night, we can play with anybody. Detroit’s been playing great basketball and had a great win streak, but we were able to come out and we played at a high level and we got the W.”

The Celtics fouled Pistons star Cade Cunningham on a halfcourt heave with 3.8 seconds remaining, sending him to the line with the chance to force overtime. Cunningham, who led all scorers with 42 points, made his first two shots but missed the third, allowing Boston to escape with a pulse-pounding upset.

Before late free throws by Anfernee Simons and Payton Pritchard, White and Brown combined to score 20 consecutive fourth-quarter points for the Celtics in a game that featured 19 lead changes and 11 ties.

The Celtics, who survived predictable rebounding struggles while Queta sat out with an ankle sprain, improved to 10-8. The Pistons fell to 15-3.

“To me, tonight wasn’t about the execution as much as it was kind of the mindset that we played with and the multiple efforts that we played with,” Celtics head coach Joe Mazzulla said. “They, from an execution standpoint, had more offensive rebounds, more free throws, etc. But I thought tonight, we just had the grit and kind of the toughness to do whatever it takes to win, and we got to try to fight for that every night.”

Mazzulla also noted the Celtics offset some of those deficiencies by shooting 47% from 3-point range and getting 20 points off turnovers.

Luka Garza, who experienced his first healthy DNP of the season in Monday night’s win over the Magic, was Mazzulla’s choice to replace Queta in the starting lineup. It was Garza’s first start since his rookie year in 2021-22, when he was playing for the Pistons.

The 26-year-old didn’t see a typical starter’s workload, however. Garza played just five minutes in the first half — Mazzulla pulled him after he let Jalen Duren slip through for a fast-break dunk — and six in the second.

Amari Williams, a rookie on a two-way contract, was Boston’s first big man off the bench; he played 15 minutes. The Celtics also deployed 6-foot-8 Josh Minott and 6-foot-7 Jordan Walsh as small-ball centers for much of the game, as they did following Queta’s injury two nights earlier. Reserve bigs Chris Boucher and Xavier Tillman both dressed but did not play.

This was the first legitimate NBA opportunity for Williams, whom the Celtics drafted 46th overall out of Kentucky in June. He’d logged just seven garbage-time minutes with Boston before Wednesday, with the vast majority of his professional action to date coming in the G League.

Williams wasn’t much of a factor on the glass (three rebounds), and the Celtics were outscored by 10 points with him on the floor, but he held his own as a rim protector with two blocks against a physical Pistons frontcourt featuring Duren and Isaiah Stewart. Overall, Detroit outrebounded Boston 56-44 and owned a 21-12 edge in offensive boards, with four different Pistons recording at least eight rebounds.

“I thought he was great,” White said. “I mean, Duren’s one of the best bigs in the league right now. (Between) him and Stewart, it’s a physical game down there, and he came in, held his own, changed some shots around the basket, blocked some shots and gave us some really good minutes in there when we needed them. So credit to him to come in his first (real minutes) — ‘Welcome to the NBA, you get Jalen Duren. Figure it out.’”

In the first quarter, the Celtics shot just 7-for-23 from the field — including a 1-for-12 start — and surrendered 18 points in the paint. But they trailed by just six, 30-24, and surged early in the second to take their first lead of the game.

The catalyst for that charge? Baylor Scheierman, who came into Wednesday with more DNP-CDs (four) than double-digit scoring efforts (one) this season. The second-year wing made his first four field goals against Detroit, including two 3-pointers and a nifty turnaround jumper that capped a 17-4 Celtics run.

Scheierman (13 points, 5-of-7 shooting) also gathered a loose ball after a Williams block and threaded a behind-the-back pass to Minott to spark a fast break. Minott, who’d put Boston ahead with an and-one 3-pointer moments earlier, was decked while attempting a transition dunk, but Williams recovered the rebound and drew a foul.

Mazzulla singled out that Scheierman hustle play and a chasedown steal by White against Jaden Ivey as two moments that invigorated the Garden crowd, which Brown called the liveliest the Celtics have played in front of this season.

Brown missed seven of his first eight field-goal attempts, then watched from the bench as Boston erased its early 10-point deficit. He found his rhythm in his second shift, scoring 10 points in three minutes while also collecting a block and two steals.

A corner three by Scheierman, off a feed from Brown, put the Celtics up 57-55 just before halftime, but Ausar Thompson countered with a long-range buzzer-beater for Detroit.

The third quarter featured seven lead changes, two ties and a revived White, who hit his first three 3-pointers of the game and drew a three-shot foul on another attempt. White also had six rebounds and six steals in the period, and the Celtics entered the fourth leading 86-83. Threes by Sam Hauser and Simons shortly thereafter — the latter off a Hugo Gonzalez steal created by stout defense from Scheierman against Cunningham — stretched Boston’s lead to seven.

Detroit cut it to one on a Stewart dunk that earned Minott, who’d unsuccessfully tried to drive through the burly Pistons big man on the previous possession, an earful from Mazzulla and a spot on the bench until the final minute. Tobias Harris put Detroit ahead with a midrange jumper, and the teams spent the next five minutes trading leads, with Brown and White providing all of Boston’s scoring.

White, who broke out of his shooting slump by making a season-high six 3-pointers on 11 attempts, appeared to ice the game when he poked the ball out of Cunningham’s grasp with 12.8 seconds remaining and the Celtics up 111-110, then hit two free throws on the ensuing possession. But Cunningham manufactured another five free-throw attempts in the closing seconds, hitting four before misfiring on the fifth.

Pritchard collected the rebound (with help from a strong Brown box-out against Stewart) got fouled and made both shots to clinch the win.

Boston now will have two days off before hitting the road for a tricky back-to-back. The Celtics will play in Minnesota on Saturday and at Cleveland on Sunday.

Other observations:

— Queta, who started the Celtics’ first 17 games, is considered “day to day,” according to Mazzulla.

“We’ll just kind of assess him every day,” the Celtics coach said pregame. “He got a little bit better today than he was when it initially happened, so we’ll just kind of take it from there each day and see how he is.”

— With the Knicks and Heat also winning Wednesday, the Celtics were officially eliminated from the NBA Cup. They finished group play with a 2-2 record and a minus-17 point differential.