IOWA CITY — The Iowa basketball team didn’t get that astonishing, head-turning, season-reversing victory it was hoping for Tuesday night.

But it couldn’t have possibly come closer.

The Hawkeyes opened an eight-point lead on No. 4-ranked Michigan State in the second half but couldn’t quite make enough plays in the last two minutes, going down to a 96-93 loss to the Spartans at Carver-Hawkeye Arena.

Nicholas Baer’s potential game-tying shot from halfcourt at the final buzzer ticked off the front rim to allow the Spartans (23-3, 11-2 Big Ten) to escape.

Miles Bridges, who led Michigan State with 25 points, had stolen an inbounds pass to seemingly secure the win for the Spartans a few seconds earlier. But Bridges, who leads the Big Ten in free throw shooting, missed two foul shots with 3.6 seconds remaining to leave the door open for a possible Iowa win.

Despite the fact that it drops Iowa two games below .500 at and ensures that it will have a losing record in the Big Ten, it was hard not to see the game in a positive light.

“It’s definitely a positive,’’ Iowa coach Fran McCaffery said. “It shows the way we’re capable of playing.’’

“I’ll remember it as a testament to how good we can be, how well we can play, how hard we can play,’’ added sophomore forward Tyler Cook, who led the Hawkeyes with 26 points.

Forward Cordell Pemsl, who scored nine of his 11 points in the second half to help the Hawkeyes grab the lead, described the game as “awesome’’ and “a huge step.’’

“A lot of positive things from tonight,’’ Pemsl said. “Any time you’re up with two minutes to go against the fourth or fifth-ranked team in the country, you’re doing something right. Tonight, we definitely showed what kind of game we can play.’’

Michigan State coach Tom Izzo opened his postgame press conference with a one-word summation of the contest: “Wow.’’

“I hope you all enjoyed the offensive fireworks tonight,’’ he said. “I don’t think either team played any defense. I know we didn’t.’’

Izzo added that he thought Iowa was “as good an offensive team as we’ve played all season.’’

The Hawkeyes (12-14, 3-10 Big Ten) trailed for much of the game before a second-half charge that included big plays by Cook, Pemsl, Jordan Bohannon, Isaiah Moss and Maishe Dailey, propelled them into an 81-73 lead with eight minutes left.

The Spartans slowly chipped away at the deficit and finally reclaimed the lead on a 3-point field goal by Kenny Goins with 2 minutes, 10 seconds to go. It was only the third 3 of Goins’ college career.

Bridges made two free throws with 1:02 remaining and two more with 31 seconds left, following a shot clock violation on the Hawkeyes. That made it 94-91.

Cook countered with another basket but Joshua Langford made two free throws for Michigan State with 6.3 seconds left.

“Obviously it’s a tough one because we battled our butts off for 40 minutes,’’ said Bohannon, who again played with the flu but managed to provide 17 points, five rebounds and six assists. “It just sucks knowing how close we were to beating one of the top teams in the country, a probable Final Four team.’’

Iowa shot 52.2 percent from the field in the game but continued to struggle at the defensive end of the floor. The Spartans shot 56.1 percent.

“It stings any time you lose a game,’’ Pemsl said. “Big picture, we played a helluva game tonight. I’m really proud of my brothers. We went to war tonight. Although it didn’t come out the way we wanted it to, it was a huge step for us.’’

Michigan St. 96, Iowa 93

MICHIGAN ST. (23-3) — Ward 7-9 3-4 17, Jackson 4-5 2-2 11, Winston 2-7 4-4 9, Langford 5-9 4-4 15, Bridges 8-14 7-9 25, Schilling 0-1 2-4 2, Goins 3-4 0-0 7, Tillman 0-2 0-0 0, McQuaid 2-5 2-2 8, Nairn 1-1 0-0 2. Totals 32-57 24-29 96.

IOWA (12-14) — Cook 11-22 4-8 26, Baer 1-4 0-0 2, Garza 4-8 1-1 9, Bohannon 6-12 0-0 17, Moss 3-8 4-5 11, Wagner 1-1 0-1 2, Nunge 1-3 0-0 2, Pemsl 4-4 3-4 11, Kriener 0-0 0-0 0, Ellingson 0-0 0-0 0, Dailey 5-7 0-0 13. Totals 36-69 12-19 93.

Halftime—Michigan St. 48-42. 3-point goals—Michigan St. 8-17 (McQuaid 2-5, Bridges 2-5, Jackson 1-1, Goins 1-1, Langford 1-2, Winston 1-3), Iowa 9-20 (Bohannon 5-8, Dailey 3-5, Moss 1-3, Nunge 0-1, Garza 0-1, Baer 0-2). Fouled out—none. Rebounds—Michigan St. 31 (Goins 9), Iowa 27 (Pemsl 7). Assists—Michigan St. 20 (Winston 8), Iowa 26 (Bohannon 6). Total fouls—Michigan St. 19, Iowa 22. A—11,350 (15,400).