LINCOLN, Neb. — For the first 39 minutes and 39 seconds of Saturday night’s game, the Kansas basketball team looked nowhere near its No. 13 national ranking.

The final 21 seconds, though, more than made up for the ugliness of the proceeding moments.

Svi Mykhailiuk hit a go-ahead 3-pointer with 21 seconds to play, Udoka Azubuike blocked, recovered and kicked ahead the would-be game-winning shot attempt on the other end, and the Jayhawks escaped with a 73-72 victory over Nebraska at Pinnacle Bank Arena.

Azubuike, who finished with 26 points on 13-for-17 shooting and 10 rebounds, struggled to protect the rim but came up huge with his first block of the game on James Palmer’s mid-range jumper with three seconds left. Mykhailiuk, who had only one 3-point make and was 5-for-15 shooting before the game-winning trey, made the most of his 2-for-7 performance from beyond the arc.

Devonte’ Graham scored 18 points on 5-for-11 shooting for the Jayhawks (8-2), who avoided what would’ve been the first three game losing streak since the 2012-13 season. Palmer had a team-high 14 points for the Huskers (7-5).

The Jayhawks entered the half with a three-point lead on the strength of double-digit scoring efforts by Azubuike (14 points) and Graham (11) but little else.

A Graham 3-pointer put KU up eight, 19-11, with 13:01 left in the period, but the Cornhuskers rallied to tie the game at 30-all and eventually entered the break trailing 36-33. Graham and Azubuike combined to go 11-for-17 shooting, but their teammates combined for only three first-half makes.

KU had seven turnovers in the opening period, including three traveling violations in a five-possession stretch, but Nebraska went 3 for 12 from 3-point range. The Jayhawks, who have struggled to get to the free-throw line this season, only made it to the charity stripe four times in the first half — all Mitch Lightfoot attempts, which he converted.

The teams traded blows in the second half until Allen’s 3-pointer — just the Cornhuskers’ fifth of the evening — made the score 51-all, brought the near-capacity crowd to its feet and caused Nebraska coach Tim Miles, on a knee on the sideline, to throw his arms in the air in jubilation.

KU coach Bill Self took a full timeout, but the Jayhawks couldn’t even muster a shot attempt in their first possession out of the breather, committing a shot clock violation. Nebraska came out of the timeout in a 1-3-1 zone and forced the error, prompting Self to insert Graham back into the contest.

The Huskers tied the game at 54 and 57 on made 3s from Glynn Watson an Isaac Copeland, but Mykhailiuk’s ensuing 3-pointer — his first make from beyond the arc of the evening — gave KU the lead. It also kick-started a 9-2 run that gave the Jayhawks some breathing room, with a Mykhailiuk layup finishing the stretch and making the margin 66-59.

Nebraska clawed back, bringing the deficit to three, 66-63, with 3:42 to play on a Watson jumper and pair of made free throws by Palmer. Isaiah Roby’s jumper made it a one-point game, and Palmer’s trey gave the Huskers a 68-66 advantage and capped a 9-0 run with 2:26 to play.

Lagerald Vick converted a dunk on a lob by Graham on the other end to make it 68-all, but two free throws from Anton Gill again gave Nebraska a two-point edge.

Mykhailiuk missed a layup on the other end, but an Azubuike put-back on a Malik Newman missed layup made it 70-all with one minute left in regulation. It was Palmer again, though, driving into the teeth of the KU defense for an acrobatic layup to put the Huskers in front again, 72-70, with 41.3 seconds left.

It all set up for the dramatic finish.