LUBBOCK, Texas (AP) Sam Ehlinger had gotten No. 15 Texas down the field with some nifty runs. The sophomore quarterback then took a shot at the end zone - and got the winning pass.

Lil'Jordan Humphrey outleaped a defender inside the 5 and then pulled him along to the end zone for a 29-yard touchdown with 21 seconds left, giving the Longhorns a 41-34 victory over Texas Tech after blowing a 17-point lead in the fourth quarter.

''I have so much confidence in him,'' Ehlinger said.

''He's as good a jump ball guy as there is in the country. We're already in field goal range,'' Longhorns coach Tom Herman said. ''If we get one-on-one coverage, we're going to try for the win.''

With Ehlinger's fourth TD pass, and second to Humphrey, the Longhorns (7-3, 5-2 Big 12) snapped a two-game skid that had cost them the Big 12 lead. They stayed a game behind co-leaders No. 6 Oklahoma and No. 7 West Virginia with two games left to determine who plays in the conference championship game Dec. 1.

Next up for the Longhorns is No. 23 Iowa State, the team they are tied with for third place.

''To battle back like we did, after a heartbreaking loss on a two-point conversion, will certainly pay dividends in the overall confidence of this team,'' Herman said, referring to the 42-41 home loss a week earlier when Mountaineers quarterback Will Grier ran for the 2-pointer in the final minute.

Texas went 75 yards in seven plays for the winning score at Texas Tech (5-5, 3-4), whose 17 consecutive points in just over 5 1/2 minutes included recovering an onside kick. The Red Raiders tied the game on Jett Duffey's fourth TD pass, a 9-yarder to Antoine Wesley with 1:45 left.

Ehlinger started the final drive with runs of 3 and 18 yards, then had a couple of short completions before a 12-yard run that set up his game-winning pass to Humphrey, who finished with eight catches for 159 yards. Devin Duvernay also caught two TDs while Ehlinger completed 22 of 34 passes for 312 yards.

''Let one go that we feel like we shouldn't let go,'' said T.J. Vasher, who had two TD catches for Tech. ''Texas played a pretty good game but we're never OK with a loss. So everybody's pretty upset right now.''

Wesley had eight catches for 171 yards and two touchdowns for the Red Raiders, who lost their third game in a row.

Duffey had 524 total yards in his second start in place of injured Alan Bowman, completing 37 of 47 passes for 444 yards and running 17 times for 80 yards. But he also had three crucial turnovers before the late comeback, throwing a pick near the end zone and fumbling twice on runs that ended inside the Texas 20.

''It would have been easy to fold after that last fumble, but he competes his tail off,'' coach Kliff Kingsbury said. ''He had a great look in his eye the entire time. ... He gave us a chance to win with his mental toughness there at the end and the way he competed.''

THE TAKEAWAY

Texas: The Longhorns were coming off consecutive losses by a combined four points. Their last four wins haven't been overwhelming - by a combined 21 points, with the win at Tech the largest margin in that span.

Texas Tech: The Red Raiders missed a chance for consecutive wins over Texas for the first time in 20 years. As much as the win in the regular-season finale in Austin last year likely saved Kingsbury's job, and got them bowl eligible, this loss could cast doubt on his future again. The former Red Raiders quarterback is now 35-38 in his six seasons as coach, and they still need one more win to get to their 16th bowl since 2000.

EHLINGER'S RECORD STREAK

Ehlinger broke the Big 12 record for most consecutive passes without an interception. The sophomore extended his streak of passes without a pick to 280, breaking the mark of 273 set by former West Virginia quarterback Geno Smith.

STUFFED ON 4th DOWN

When the Red Raiders tried to convert fourth-and-1 from their own 34 before halftime, Duffey was immediately stuffed and Texas needed only four plays before Keaontay Ingram's 2-yard TD run to go up 17-7.

BOWMAN SITS OUT

Bowman had another four-night hospital stay after taking a hit in last week's 51-46 loss to Oklahoma, leading to a recurrence of a partially collapsed lung the standout true freshman initially suffered earlier this season. He was on the sideline before the game, but not in uniform.

UP NEXT

Texas is home Saturday night to play Iowa State, which has a five-game Big 12 winning streak.

Texas Tech plays at Kansas State next Saturday.

---

More AP college football: https://apnews.com/Collegefootball and https://twitter.com/AP-Top25

Copyright 2018 by AP. Any commercial use or distribution without the express written consent of AP is strictly prohibited.