Indiana’s Christian Watford celebrates with the tournament trophy after the top-ranked Hoosiers closed out the Hoyas to win the Legends Classic in Brooklyn. (Elsa/Getty Images)

One night after toppling No. 13 UCLA with spirited defense and an in-sync offense, Georgetown nearly replicated its heroics against top-ranked Indiana in the championship game of the Legends Classic at Brooklyn’s Barclays Center.

After trading the lead throughout only to fall behind on a late-game run by Indiana, Georgetown tied the score on jumper by Otto Porter Jr. with 4.6 seconds remaining in regulation.

But in overtime, Indiana drew the fouls and made the shots to stave off the upset, prevailing 82-72 in a game that ended early Wednesday morning.

Indiana was led by 7-foot center Cody Zeller, who scored nine of his 17 points on the free-throw line. The hard-charging Hoosiers were frequent visitors to the stripe throughout the game, taking 36 free throws in the game to Georgetown’s 10. (The differential at the end of regulation was 19-2.)

Despite the defeat, Georgetown (3-1) leaves New York with a victory against a ranked team and an impressive showing against the No. 1 squad, which ought to bolster the young Hoyas’ confidence and suggests that prognosticators overlooked something in omitting the Hoyas from the preseason rankings.

It was scant solace to Georgetown Coach John Thompson III.

“We came here to win. We had our chances,” Thompson said. “We’re extremely disappointed in how things turned out. But they’re a very good team. The best team in the country.”

Junior guard Markel Starks, who followed his career-high 23 points against UCLA with a game-high 20 points, said the Hoyas had every right to feel confident regardless of others’ expectations.

“I can play,” said Starks, named to the all-tournament team. “And we have a team full of guys that can play.”

It was the first meeting between Georgetown and Indiana (5-0) in 33 years.

Though Indiana’s campus is nearly 800 miles from New York, Hoosiers dominated the crowd and booed the Hoyas when they trotted out for warm-ups and chanted “I-U!” at every opportunity.

Georgetown did a terrific job of moving the ball around, getting its first four baskets from four different players, and took a 14-10 lead.

With Indiana’s Zeller clogging up the paint, it was difficult for Georgetown to penetrate. Starks compensated nicely, hitting all three of his three-point attempts in the first 10 minutes. Greg Whittington (12 points) followed suit, staking the Hoyas to a 23-18 lead.

Then came a string of fruitless Georgetown possessions, and Indiana sprinted to a 15-3 run.

Whittington hit a three-pointer from the corner to snap his team’s futility. With another by Jabril Trawick, it was a one-point game. But Indiana took a 36-32 lead at the break.

Georgetown came out re-energized in the second half.

With Porter (15 points) finding his touch, Georgetown pulled within one, 44-43. But forward Mikael Hopkins drew his fourth foul on the next play, and it was all Thompson could do to keep from erupting.

Trawick stepped in and provided an immediate spark, as he had after Hopkins got into early foul trouble against UCLA.

Porter reclaimed the lead for Georgetown with 11:32 remaining, and Trawick followed with a pair.

Indiana countered with back-to-back 3-pointers, and Starks slashed to the rim for a pretty finger roll to knot it at 51 apiece.

The Hoosiers stormed back with an 8-0 run. Hopkins, re-inserted for the final push, made a strong move to the basket and completed a three-point play. He fouled out with 1:18 remaining, Indiana leading 61-56. Starks and Trawick fouled out in overtime.

“They do a good job of drawing fouls,” Thompson said of Indiana, which hit 26 of its 36 attempts from the line. “They did it again tonight, and they make most of their foul shots.”

In Tuesday’s consolation game, UCLA edged Georgia, 60-56, with the Bruins’ Shabazz Muhammad contributing a game-high 21 points in the second outing of his college career.

Georgetown returns to Verizon Center Saturday for a noon game against Mount St. Mary’s.

NOTE: Florida Coach Billy Donovan said Tuesday that he’d like to finish the aborted season-opener against Georgetown before conference play for either school. The game was canceled at halftime, with Florida leading, 27-23, because condensation on the flight-deck court of USS Bataan made conditions hazardous for players.