Fifteen seconds.

That’s how long, in real time, it took for Hugo Gonzalez to step onto the court at the Barclays Center and hit the biggest shot of his young NBA career.

Gonzalez’s game-tying overtime 3-pointer, which forced a second OT in Boston’s 130-126 win over the Nets on Friday night, was the result of a last-second audible by head coach Joe Mazzulla.

Down by three with 2.5 seconds remaining, the Celtics initially sent out a lineup of Payton Pritchard, Baylor Scheierman, Jaylen Brown, Sam Hauser and rookie center Amari Williams. But as Scheierman prepared to inbound the ball in the frontcourt, Mazzulla pivoted, calling Williams to the bench and inserting Gonzalez.

Matched up against Michael Porter Jr. at the right elbow, the rookie wing looped beneath the basket to the left corner while Brown jogged in from above the 3-point arc and settled near the free-throw line. Brown’s entry drew the attention of Porter and Nic Claxton, which busted Brooklyn’s zone defense. No one followed Gonzalez, allowing him to receive a short pass from Scheierman and loft a catch-and-shoot three.

Hauser raised his hands in celebration before the ball reached the basket. Once it did, Gonzalez’s teammates mobbed him.

The Celtics, who’d blown a 10-point lead in the final three minutes of regulation, pulled ahead midway through double OT and held on for a roller-coaster victory.

After the game, Mazzulla explained the decision to swap out Williams for Gonzalez. The change gave the Celtics five capable outside shooting options as Gonzalez is shooting 38.2% from three this season.

“We had Amari out there just in case they matched up in a certain coverage, and it looked like they were going with something different,” Mazzulla told reporters. “So we just wanted to get Hugo out there, and Hugo made a great play. It’s a credit to him. He’s always ready, and he made a good play.”

Mazzulla added: “The play wasn’t necessarily for him. (Situations where you) need threes are a crapshoot. You never know what defense they’re in. … So it was really just a read where those four guys had to make a play. Hugo made a great play, and Baylor made a great pass.”

Nets head coach Jordi Fernandez called his team’s breakdown “a miscommunication” that led to “a wide-open shot.”

The clutch bucket was the latest highlight in an impressive rookie season for Boston’s youngest player, who’s looked like a first-round draft steal since October. The 19-year-old Gonzalez totaled 10 points on 4-of-4 shooting (2-of-2 from three), seven rebounds, one steal and one block in 19 minutes in the win.

Rookie center steps up

Williams expected to be playing Friday night — but for the Maine Celtics, not their NBA parent club.

But after starting center Neemias Queta came down with an illness before Boston’s game in Brooklyn, the team called up Williams for extra frontcourt insurance. And after Queta and his backup, Luka Garza, both fouled out, Mazzulla turned to the rookie two-way player to help the Celtics secure one of their wildest wins of the season.

Williams, after sitting for all of regulation and nearly the entire first overtime session, subbed in with 7.9 seconds left, received a long-range inbounds pass from Sam Hauser and fed Payton Pritchard for a quick 3-pointer.

After Gonzalez hit his game-tying corner three on the next Celtics possession to force a second OT, Williams played the rest of the way. He converted a go-ahead and-one layup — just the second made field goal of his young NBA career — and later punctuated the victory by swatting away a shot from Nets guard Nolan Traore with 40.6 seconds to play.

The late block capped a whirlwind day for the second-round draft pick.

“Funny enough, this game, I flew in two hours before from Maine,” Williams told reporters postgame, via CLNS Media. “I did the shootaround this morning, thought I was going to play there tonight, and then Neemi wasn’t feeling great, so I flew in today. Just kind of being ready for whatever. You don’t really know until you get here if you’re going to suit up or not, so just kind of being ready for whatever.”

Williams also held up well on the glass in his five minutes of floor time. The Nets registered just one offensive rebound in double OT after pulling down 12 between the fourth quarter and the first overtime.

“Amari comes in, he ain’t played much this year, and big rebounds, a big and-one, a blocked shot,” Pritchard said in a postgame interview with NBC Sports Boston’s Abby Chin. “It takes a team, man. Everybody’s stepping up, and tonight, we needed it.”

Drafted 46th overall out of Kentucky last summer, Williams has logged just 52 minutes for Boston this season, most of those coming late in blowouts. But he’s posted encouraging numbers in the G League, averaging 17.3 points, 11.7 rebounds, 4.4 assists and 1.8 blocks since Maine’s regular season began.

Mazzulla praised the 23-year-old for his readiness.

“For Amari to be able to sit through the entire game and be ready and execute some of the plays that we’ve gone over in practice, it’s a credit to him and the coaching staff,” the Celtics coach told reporters in Brooklyn. “Those are the guys that work with him, getting him ready to go, and say the same thing for Hugo’s mindset. Those guys made big plays, and the (player development) staff gets those guys ready to go every day.”