IOWA CITY, Iowa -- After nearly six hours and 18 innings of baseball, John Barrett solidified No. 24 Iowa's fifth consecutive win and fourth walkoff in the past eight games with a game-winning sacrifice fly to close out a 4-3 win against Sacramento State on Tuesday night at Duane Banks Field.

"It was a huge win for us going into the weekend and coming off a doubleheader," Iowa head coach Rick Heller said. "I was a little worried about us coming out flat today and not having everyone healthy. It was big to get the win ... when you play that long you never want to lose.

"As bad as we were offensively and with the opportunities we squandered, our pitching was outstanding. We got out of jams, pressured situations and ultimately got the job done when we needed to."

Tied at three heading to the bottom of the 18th, Eric Toole ignited a struggling offense with a single to right field to lead off the inning. With one away and Toole at first, Kris Goodman came through with a single to left field and both runners moved up a base on a Hornet fielding error.

Barrett -- who entered the game in the 12th as a pinch-hitter -- stepped into the box with one away and runners at second and third. After previously going 0-for-3 at the plate, he delivered a deep fly ball to center field that allowed Toole to tag up from third and plate the game-winning run.

"On nights like this, you hope the team stays focused and wants to win as bad as I do," Heller said. "This team finds ways to win regardless of the situation. This group is special, and they've got a talented group of seniors leading them. They're competing for a championship, and they've got their minds in the right spot to go out and compete on a daily basis."

Initially trailing 2-0, Iowa's early offense came in the fifth inning, all with two outs. The Hawkeyes (31-11) scored a pair of runs off four consecutive hits. Joel Booker got things started with a double down the left field line before scoring on an RBI single from Toole. Jake Mangler and Goodman followed with back-to-back singles with Goodman's base knock plating the game-tying run.

Going into extra innings at 2-2, the Hornets took a 3-2 lead in the 12th. Nathan Lukes scored the go-ahead run after reaching on a double and he scored on a Brandon Hunley sacrifice fly.

Iowa answered in the bottom of the frame, generating the game-tying run off a pair of defensive errors. Corbin Woods entered the game for Sean Moore as a pinch runner and crossed the plate when Hornet shortstop Scotty Burcham airmailed a throw trying to gun down Woods at the plate, tying the game at three.

The Hawkeyes left two on in the 12th inning and the bases loaded in the 15th and 17th innings before finally breaking through in the 18th.

Iowa's pitching staff was superb as eight Hawkeye pitchers limited Sacramento State to three earned runs in 18 innings. Six of the eight pitchers didn't allow a run and five threw at least two innings in the contest.

Brandon Shulista (2-2) earned the win, throwing the final two innings and allowing just one hit. Sacramento State's Jeremiah Moore (0-1) suffered the loss, allowing one unearned run in 1.1 innings.