The 14th-ranked Nittany Lions, sparked by the passing of Kerry Collins, scored the game's final three touchdowns.
Collins completed 23 of 42 passes for 352 yards and three touchdowns as Penn State, 9-2 overall and 6-2 in the Big Ten Conference, appears set for the Citrus Bowl.
"We had to throw it more today than we planned to," Collins said. "We used our two-minute drill a lot more than two minutes. It has never, ever gone as smooth as it did today, even as much as we practice it."
Michigan State (6-4, 4-3) closes its season Saturday against Wisconsin at Tokyo.
The No. 25 Spartans, who appear headed for the Liberty Bowl, scored the first two touchdowns of the third quarter to take a 37-17 lead with 2:54 to play in the quarter.
The comeback started when Derek Bochna intercepted a pass by Michigan State's Jim Miller, who completed 14 of 29 passes for 186 yards and two touchdowns.
Collins completed a 40-yard touchdown pass to Bobby Engram with 53 seconds left in the third quarter.
Two plays later, Penn State recovered a fumble by Michigan State tailback Duane Goulbourne, leading to a three-yard touchdown run by Brian O'Neal that cut the deficit to 37-31.
Penn State forced the Spartans to punt on their next possession. The Nittany Lions got the ball at their 48, and Collins threw a touchdown pass to Engram on the first play.
Craig Fayak's conversion gave Penn State the lead for the first time, 38-37, with 11:21 to play.