EAST LANSING, Mich. (AP) - Undaunted by the nation's top-ranked pass defense, MarQueis Gray and Da'Jon McKnight nearly pulled off another upset against a team with Big Ten title aspirations.

Gray threw three touchdown passes to McKnight, but No. 15 Michigan State came away with a 31-24 victory over Minnesota on Saturday. Le'Veon Bell's 35-yard touchdown run with 10:58 remaining broke a 24-24 tie.

"We wanted to take a few shots," Minnesota coach Jerry Kill said. "Game plan-wise, I think we gave ourselves a chance to win. We did on defense also."

Bell ran for 96 yards and two touchdowns, and Kirk Cousins threw for 296 yards and a pair of TDs. The Spartans (7-2, 4-1 Big Ten) trailed 24-21 after three quarters before rallying.

The Golden Gophers (2-7, 1-4) upset Iowa last weekend and had a chance to do the same to Michigan State, but with the score tied, Bell found running room to the right and went all the way to the end zone to put the Spartans ahead.

Minnesota had the ball at the Michigan State 45 with 15 seconds left, but Gray threw an interception.

"He played awfully good. He gave us an opportunity," Kill said. "I think at the end of the game, the kid was physically exhausted. He gave everything he had but that's how you learn."

Gray was 19 of 32 for a career-high 295 yards with three touchdowns and two interceptions, and McKnight caught nine passes for a career-high 173 yards.

Michigan State entered the game ranked No. 1 in the nation in pass defense, but Gray and McKnight didn't seem to notice. The 6-foot-4 quarterback found his senior receiver with a short pass early in the first quarter, and McKnight slipped past three potential tacklers before eventually dragging defensive back Johnny Adams into the end zone for a 64-yard touchdown to open the scoring.

"They kind of played soft at the beginning on me, so I guess they really didn't respect us," McKnight said. "So toward the end they tried to press, but we're a good offense too. They're good, but we're good too."

Cousins answered with a 4-yard scoring pass to Keith Nichol, but a fumble by the Spartans' Edwin Baker later in the quarter gave Minnesota the ball at the Michigan State 26. Gray's 13-yard touchdown pass to McKnight put the Gophers back ahead.

"He's a playmaker," Gray said. "People know that you have to put the ball in the playmaker's hands. He's been doing a great job at that for us."

The Spartans tied it at 14 on a 1-yard scoring run by Bell in the second quarter, but Michigan State still looked out of sorts. A short while later, the Spartans had the ball inside the Minnesota 20 when there was movement up front for a false start. An annoyed Cousins took the snap and spiked the ball in exasperation, drawing an unsportsmanlike conduct penalty and knocking his team out of field goal range.

"I was playing with emotion and got frustrated," Cousins said. "There's a lot on the line, and I'm a senior. I want to go out the right way."

Down 17-14 in the final minute of the half, Michigan State finally found a rhythm, driving 74 yards and taking the lead on a 2-yard touchdown pass from Cousins to Todd Anderson with 5 seconds left in the second quarter.

It was Anderson's first career touchdown.

The advantage was short-lived. Minnesota went 80 yards in 11 plays at the start of the third and took a 24-21 lead when Gray found McKnight in the back of the end zone for a 15-yard touchdown on third-and-12.

Michigan State had a touchdown wiped out by a replay review later in the third. A sideways pass from Cousins to Bell hit the ground, and Minnesota defensive back Kyle Henderson stopped, assuming the play was over. Bell picked up the ball and ran 60 yards to the end zone, but after further review, officials ruled the pass went forward and changed their call to an incompletion.

Dan Conroy tied it at 24 with a 40-yard field goal 11 seconds into the fourth quarter, after tight end Brian Linthicum made a nice play in the end zone to prevent a possible interception. That drive started at the Minnesota 41 after Trenton Robinson's acrobatic interception of Gray.

Robinson also made the interception in the final seconds that sealed the win for Michigan State.

(Copyright 2011 by The Associated Press.  All Rights Reserved.)