Maryland football’s chances looked bleak for most of Saturday night. That changed when Billy Edwards Jr. trotted into the end zone untouched on a read-option with less than a minute remaining.

After the ensuing extra point, the Terps overcame a two-touchdown deficit from early in the fourth quarter and led by one.

USC had a final chance to thwart the comeback on fourth-and-2 at Maryland’s 40-yard line with 14 seconds left. Linebacker Caleb Wheatland broke up Miller Moss’ pass to Woody Marks, sending the Terps’ sideline into a frenzy on a play that sealed Maryland’s 29-28 home victory.

The Terps were on the verge of a third straight loss and a tumble toward the bottom of the Big Ten standings — instead, they got their first victory in nearly a month. It was a monumental point in Maryland’s (4-3, 1-3 Big Ten) season that vastly increased its likelihood of reaching a bowl game for a fourth straight year.

“We needed this to build,” coach Michael Locksley said. “I think what y’all saw was this team grow right before your eyes.”

The win was unlikely with three minutes left.

USC (3-4, 1-4 Big Ten) sacked Edwards on fourth down as the quarterback struggled to find an open receiver, an 18-yard loss that gave the Trojans offense starting position at the Terps’ 33-yard line. USC led by six and any score would’ve sealed a win.

[Billy Edwards Jr. played the long game. It could make him Maryland’s quarterback.]

But Maryland’s special teams, which was sloppy at times throughout the night, blocked a field goal attempt that set up Edwards’ game-winning drive.

Edwards was excellent besides a third-quarter interception. He completed 78 percent of his passes for a career-high 373 yards and two touchdowns along with his rushing score.

Edwards and Moss each fired 50 throws in a pass-heavy game.

Moss shined against a Terps secondary that missed safety Dante Trader Jr. for a second straight contest. He torched Maryland with 336 yards and three scores.

The Trojans’ talented receivers aided Moss’ performance. They connected on seven plays for more than 15 yards in the first half, including each of Moss’ early touchdowns. Ja’Kobi Lane fought through tight coverage from cornerback Perry Fisher to snag the second score with his left hand while turning his body around.

USC went to the ground for its final first-half touchdown. Back-to-back Marks rushes resulted in 15 yards and a score to go up 21-7 at halftime.

Moss’ first mistake came on his fourth throw of the second half, a back-footed floater that safety Lavain Scruggs intercepted. A long return set Maryland’s offense up for an 18-yard touchdown.

“Huge play in the game,” Wheatland said. “That’s just what we do.”

Moss later led a 10-play drive and capped it off with a 26-yard touchdown to Duce Robinson, extending the lead to 28-14 shortly into the fourth quarter. But that was the Trojans’ final score — their last three possessions were a punt, a blocked field goal and a turnover-on-downs.

[Maryland football’s offseason transfers haven’t lived up to expectations]

The second half was nearly the opposite of the first, when Maryland’s lone pre-halftime touchdown was a 16-yard strike from Edwards to Octavian Smith Jr. The score was Smith’s first in over a year. He finished with a career-high 84 yards.

More than 70 percent of Locksley’s first-half play calls were passes despite facing a Trojans defense that entered Saturday allowing the third-most rushing yards per game mark in the Big Ten.

“In the first half they played a little more man [defense] than we were anticipating,” Edwards said. “Going into halftime we knew … we got the skill guys that were built for it.”

While Locksley increased the ground game usage early in the second half, Maryland’s offense still relied on Edwards. The quarterback combined with Tai Felton for a touchdown for the sixth time this season one play after Scruggs’ interception.

Roman Hemby’s fourth carry of the game, a strong run into the end zone for a 10-yard touchdown, brought the Terps back within one score. Locksley elected for a two-point try and was rewarded when Kaden Prather snagged an Edwards pass to trim the deficit to 28-22.

The Terps got the touchdown they needed nine minutes later. They snapped their season slide.

“That was the breakthrough that we’ve been waiting for,” edge rusher Donnell Brown said.