Glen Oaks was close to tasting what would have been one of the biggest upsets of the boys basketball season.

The Panthers had the ball and a five-point lead over University High with 1 minute, 50 seconds to play, but the Cubs showed why they are the top team in the Division II power ratings.

But U-High erased its deficit, scoring the final 12 points as it rallied past feisty Glen Oaks 61-54 in District 6-3A action Friday night at the Panthers gym.

“We were up five points with a minute or so to go, and it was just a costly turnover by our point guard floating a pass over out of that trap,” Glen Oaks coach Harvey Adger said. “But I was really proud tonight. We competed hard against a great group of kids. We really battled against a great team. The turnover at the end hurt us.”

U-High (19-2, 4-0) trailed 28-22 at halftime but got a boost from forward Nick Flory, who scored 15 of his team-high 17 points in the third quarter. Flory opened with a three-point play and added four 3-pointers, helping the Cubs take their largest lead, at 46-35, late in the quarter.

“It was fun. At halftime, coach (Joe Spencer) said we needed to get some rebounds and play harder,” said Flory, who found his shooting touch. “We had some plays called for me, and I just kept knocking them down. It felt good.”

The Cubs settled for a 46-41 lead entering the fourth quarter.

For Glen Oaks (8-16, 2-2), James Weathers opened the final quarter on a tear with two baskets, a steal and an assist as the Panthers took a 48-46 lead. Weathers topped Glen Oaks with 18 points.

After a 49-49 tie, Brian Dundy scored two of his 13 points to put Glen Oaks up 51-49. Dontrell McQuarter got a two-handed jam after a steal and later hit a free throw for Glen Oaks’ 54-49 lead with 4:36 left to play.

U-High came up empty on its next three trips downcourt, but Glen Oaks couldn’t take advantage. The Panthers had three turnovers, the last an errant pass by Weathers near midcourt.

Spencer Mays made two free throws, and John Jones hit a 3-pointer from the right wing to tie the score at 54 with 1:21 left.

Glen Oaks closed the game missing its last five shots. Mays gave Glen Oaks the lead for good with a 3-pointer, then put the game away with four free throws in the closing seconds.

“I expected Glen Oaks to be one of the best teams coming into the year, and I think they’re better than their record,” Spencer said. “Some of these games are a lot harder than people realize. That’s a great team with a great coach that wants to win just as badly as the other team.”