Penn State quarterback Trace McSorley (9) hugs wide receiver Saeed Blacknall (13) after a 38-31 win against Wisconsin in the Big Ten championship at Lucas Oil Stadium in Indianapolis on Saturday, Dec. 3, 2016. (Abby Drey/Centre Daily Times/TNS)

INDIANAPOLIS — After Penn State fell behind Wisconsin by 21 points in the second quarter and went into halftime of the Big Ten championship game trailing 28-14, the thought of the thousands of its white-clad fans in Lucas Oil Stadium had to be whether the Nittany Lions still had that second-half magic.

They did.

Trace McSorley, who threw four touchdown passes in the game, led the Lions to points on each of their first four possessions of the second half in a record-breaking performance, carrying Penn State to the Big Ten championship with a 38-31 victory over the Badgers on Saturday night.

The win, the ninth in a row for Penn State (11-2), guaranteed the Nittany Lions a berth in the Rose Bowl on Jan. 2. They will have to wait until Sunday to see if they can grab a spot in the College Football Playoff, but that is a bit of a long shot.

McSorley hit his first seven passes of the second half, including touchdown throws of 70 yards to Saeed Blacknall — on the team’s first play of the third quarter — and 18 yards to Saquon Barkley. The pass to Barkley early in the fourth quarter gave Penn State the lead for good at 35-31.

Barkley, who rushed for 83 yards on 19 carries, also scored on a 1-yard run. Tyler Davis kicked a 24-yard field goal with 5 minutes, 14 seconds to play, giving Penn State a seven-point lead.

The Badgers moved methodically into Penn State territory on their final drive, but on fourth-and-1 from the Lions 24, Corey Clement was stopped by Grant Haley short of the sticks with 1 minute, 1 second to play, and the Lions ran out the clock.

McSorley completed 22 of 31 passes for 384 yards, a Big Ten championship game record. Blacknall, who also caught a 40-yard scoring pass from McSorley, caught six passes for 155 yards, another record for the contest.

McSorley’s other touchdown pass, one of 33 yards, went to tight end Mike Gesicki in the first quarter.

The Badgers built their 28-7 lead with the help of a 67-yard run in the first quarter by Clement. They also got a 12-yard fumble return for a touchdown by linebacker Ryan Connolly after McSorley failed to cover up a bad snap, a score that made it 21-7.

When Dare Ogunbowale scored on a 7-yard run with just over five minutes left in the first half, Wisconsin held a 28-7 lead and the Nittany Lions were having trouble handling the Badgers’ pass rush and linebackers.

But Penn State went right down the field at the end of the half and got to within two touchdowns on McSorley’s 40-yard pass to Blacknall, the first of three touchdowns in an 11:36 span extending into the third quarter.

The Nittany Lions cut a 14-0 deficit in half when McSorley launched a pass into the end zone, where the 6-foot-6 Gesicki outjumped 6-foot cornerback Lubern Figaro and hauled it in for a 33-yard score with 1:10 left in the first quarter.

On their next possession, the Lions had third-and-a-foot at their own 31, but center Brian Gaia’s shotgun snap eluded McSorley. McSorley dove for the ball but couldn’t control it, and Connolly scooped the ball up and dashed 12 yards for a touchdown to make it 21-7.

Penn State gambled unsuccessfully on fourth downs on its next two trips because its offensive line was unable to keep the Wisconsin pass rush off McSorley.

The first time, fourth-and-2 at the Penn State 42, was blown up by heavy pressure that forced McSorley to throw the ball away. The next fourth-down play, with one yard to go from the Wisconsin 48, ended with a sack of McSorley by T.J. Watt, and the quarterback had to be helped off the field.

The Badgers took advantage of the short field after the first turnover on downs by the Lions, driving 42 yards in five plays and getting a break when Clement’s fumble was recovered by teammate Zander Neuville to help them retain possession. Ogunbowale went in from 7 yards out for the touchdown and a 28-7 Wisconsin lead.

Penn State scored its second touchdown before the end of the half, twice converting third downs on completions of 18 yards to DaeSean Hamilton and 12 yards to Blacknall. From the Wisconsin 40, McSorley threw a deep out to Blacknall, who eluded Figaro and went the distance for the score with 58 seconds to play.