MANHATTAN, Kan. — Kansas State made the Mountaineers sweat it out at the end, but Jarret Doege’s first game as the West Virginia University starting quarterback was a victorious one.

Doege, a Bowling Green transfer who saw his first game action with WVU last week before getting the start Saturday, completed 20 of 30 pass attempts for 234 yards and three touchdowns with no interceptions as the Mountaineers snapped a five-game losing streak with a 24-20 win Saturday at Kansas State.

It was West Virginia’s first win since beating Kansas 29-24 on the road in late September.

“It felt a long time coming,” first-year WVU coach Neal Brown said. “[We have] kind of been knocking on the door. I told our staff earlier in the week, I really felt like we’d be in the position at some point to win a game or win more than we game that we shouldn’t have. We come in here against the No. 24 team in the country [in the College Football Playoff ranking] that beat Oklahoma on this field. It’s a big win for our program. It’s big for our players and I’m proud of our guys.”

K-State (6-4, 3-4 Big 12) opened the scoring on its first play from scrimmage. After the Wildcat defense forced a quick punt on WVU’s first drive, KSU quarterback Skylar Thompson hit receiver Dalton Schoen over the top for a 68-yard touchdown pass to give K-State the early lead.

The Mountaineers (4-6, 2-5 Big 12) and Doege, however, had an answer on their next possession. Doege and the WVU offense moved the ball 75 yards on six plays, with graduate transfer receiver George Campbell bringing in a 19-yard touchdown pass. Casey Legg’s extra point tied the score at 7.

“I knew once we did that, we were going to be in this game until the fourth quarter,” Brown said. “That has been our goal all year. Let’s get these games in the fourth quarter and let’s see what happens, and we’ve done that with the exception of two.”

K-State added a Blake Lynch field goal to take a 10-7 lead later in the quarter, but the Mountaineers — and Campbell specifically — would strike again before the second quarter.

Doege found Campbell for a 15-yard touchdown pass on the final play of the period, and Legg’s extra point gave West Virginia a 14-10 lead.

Neither team found much success moving the ball in the second quarter before K-State added another Lynch field goal with 43 seconds to play in the half to make it 14-13. The Mountaineers did have a chance to increase the lead before the break, but after a quick drive into K-State territory Legg’s 37-yard field goal attempt was wide left as time expired.

Kansas State got the ball to start the third quarter and went right to work. The Wildcats converted two third downs along the way on a 13-play, 70-yard drive that took more than seven minutes off the clock and ended with a 3-yard touchdown run by James Gilbert to put K-State ahead 20-14.

That score held until early in the fourth quarter, when Legg made up for his earlier miss with a 51-yard field goal to cut into the K-State lead and make the score 20-17.

WVU’s next possession appeared doomed with the Mountaineers facing third-and-22 from midfield, but Doege made an athletic play to avoid the K-State pass rush and threw a deep pass as he took a big hit to a wide-open Bryce Wheaton for a 50-yard touchdown to put the Mountaineers ahead 24-20 with a little more than 11 minutes to play.

“I was thinking, ‘Just get through my progressions,’ but I was forced out of the pocket,” Doege said. “I saw Bryce standing there wide open and fortunately I got it off before I got hit. I didn’t know exactly if he caught it or what happened until I looked up and he was in the end zone.”

K-State moved the ball into WVU territory on its next possession, but Thompson’s fourth-down pass attempt was broken up by West Virginia senior quarterback Keith Washington. K-State got one more chance, but Bailey’s interception put the Wildcats away for good. It was KSU’s second consecutive loss after falling last week at Texas.

“I thought they outplayed us,” K-State coach Chris Klieman said. “All that being said, we had an opportunity late in the game to almost steal a victory. So, [I’m] disappointed in a number of things, but we’ve got to move on. We’ve got to move forward.”

West Virginia, for the first time in a while, managed an efficient running game against K-State, finishing with 85 yards as a team with sophomore Leddie Brown leading the Mountaineers with 62 yards on 13 carries. Campbell finished as West Virginia’s leading receiver Saturday with five catches for 92 yards.

“We challenged our guys and talked about being accountable, what the expectations are and what the standards are for this program,” Brown said. “I thought they showed character — competitive character.”

For Kansas State, Thompson completed 24 of 39 passes for 299 yards and two interceptions. James Gilbert led the Wildcats on the ground with 60 yards on 13 carries. As a team, KSU finished with 421 total yards. West Virginia, meanwhile, amassed 319.

The Mountaineers return home next Saturday for Senior Day against Oklahoma State.

Contact Tom Bragg at tom.bragg@wvgazettemail.com or 304-348-4871. Follow him on Twitter @TomBraggSports. Read Tom’s WVU sports blog at http://blogs.wvgazettemail.com/wvu/.