LAWRENCE, Kan. (AP) -- It was Kansas' game to win or lose. The Jayhawks had a three-point lead and appeared to have the game locked down, and the sideline was roaring.
But a Texas touchdown with 12 seconds on the clock left the Jayhawks deflated and disappointed with a 21-17 loss on Saturday, spoiling Kansas' homecoming game.
"I basically told them I feel really bad for all of them today," said Jayhawks coach Charlie Weis. "Every week is a different circumstance. I feel that there's nothing to be embarrassed about. We played our tails off on both sides of the ball."
Kansas got 176 yards rushing from James Sims, who became the first Jayhawk with four straight 100-yard games since 1991. It wasn't enough.
D.J. Grant caught the winning 1-yard touchdown pass from Case McCoy, who replaced an ineffective David Ash in the fourth quarter and engineered a drive in the final 2 minutes for the Longhorns (6-2, 3-2 Big 12). Taking over on the 30 after Kansas' Nick Prolago hit a 29-yard field goal for a 17-14 lead, McCoy and the Longhorns were unstoppable. He hit Jaxon Shipley for 18 yards on fourth down, then connected with Mike Davis for 39 yards to the 3.
On third-and-goal from the 1 and with Kansas crowding the line of scrimmage, Grant sneaked into the end zone and cradled McCoy's softly tossed pass for the winning TD.
"Our team and our coaches decided to dig down deep and decided to fight," said McCoy. "We came out slow and sluggish, and that is definitely something we cannot do the rest of this year. We are lucky we came out of here with a win."
On that, he'll get no argument from the downcast Jayhawks (1-7, 0-5), who were straining to end a 16-game conference losing streak and are 0-10 against Texas since the Big 12 was formed.
Weis may come in for criticism for his management of the game clock during that final drive. Weis called a timeout with 1:16 left when Texas was driving, but he kept two more in his pocket while the clock continued to run with Texas near the goal line.
"Our best chance right there was to make a goal-line stand," Weis said. "I was personally hoping they got down to the 6-inch line and instead of kicking a field goal, they go for it and we make a stand and we're all partying right now. It just didn't work out the way I planned."
"It's crazy how just a couple of plays can change the game," Sims said. "We were in it until 12 seconds left and they ended up scoring the touchdown."
While the defense held Texas well under its 44-point average, the woes of the Jayhawks' special teams prevented Kansas from creating a gap. Kansas fumbled four times -- twice on kickoff returns.
"The way we're playing football right now, we don't have a big margin of error," said Weis.
The Jayhawks battled poor field position throughout the game but scored three of their four times in the red zone. Kansas relied heavily on its run game, with 234 of its 273 yards of offense coming on the ground. The Jayhawks scored two rushing touchdowns in the first half -- Tony Pierson's 11-yarder and Christian Matthews' 15-yarder -- but could not get into the end zone after halftime.
The Longhorns tied it at 14 on an 11-yard run by Marquise Goodwin following his 41-yard run on an end-around in the fourth quarter.
Sims said the locker room was somber after the game.
"There is a lot of disappointment, but it kind of brings out the hunger," Sims said. "Next week we're going to be ready to go."
In the third quarter, linebacker Huldon Tharp led a defensive stand that stopped Joe Bergeron on fourth-and-goal from the 2 and gave the Jayhawks a huge lift.
"It was on our back," he said. "It was up to us to win the game. That's exactly what we talked about."
He said the defense was determined to stop the Longhorns on that final drive.
"Before we went out, we looked each other in the eyes and told each other, `We got to get this.' But it just didn't happen."
Copyright 2012 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.