RALEIGH, N.C. -- North Carolina State didn't quit on the season when things looked bleakest. The Wolfpack refused to give up on the finale, either.

Trailing the ACC's worst team by four touchdowns, N.C. State came up with the biggest rally in school history -- and all but assured itself of one more game.

Mike Glennon threw for a career-high five touchdowns, ran for another score and helped North Carolina State come back from 27 points down in the second half Saturday to beat Maryland 56-41.

James Washington ran 1 yard for the go-ahead score with 7:08 left for the Wolfpack (7-5, 4-4 ACC), who trailed 41-14 with six minutes left in the third quarter before scoring six straight times they touched the ball during the second-biggest comeback ACC history -- and a victory that might have been more shocking than last week's upset of Clemson.

"When this football team was 2-3, there weren't a lot of people that believed we could win five out of the next seven games except the people in this building," coach Tom O'Brien said. "You hitch up your britches, you buckle your chin strap, you go to work and you start grinding. And that's what we did. ... There's probably not a lot of people, in the middle of the third quarter today -- except those guys on the bench -- who would have believed that the outcome would have been (what) it was."

The Wolfpack scored 35 points in the fourth quarter as part of a rally surpassed in an ACC game only by Clemson's comeback from a 28-point deficit to beat Virginia 29-28 in 1992.

"It's the greatest thing I've ever been a part of," tight end George Bryan said.

C.J. Brown rushed for two touchdowns and threw for another for Maryland (2-10, 1-7), which lost its last seven games under first-year coach Randy Edsall and dropped its school-record fifth in a row by double figures. Davin Meggett's 46-yard scoring run in the third quarter gave the Terrapins their biggest lead.

"This is the way our season has gone," Brown said. "We could not put together a full game. We had to step up and make a play and we couldn't."

Glennon finished 36 of 55 for 306 yards and became the second Wolfpack player to account for six TDs in a game, joining Philip Rivers in that exclusive club.