Jonathan Holmes missed badly on a long 3-pointer for the Longhorns in the final seconds, but Ridley emerged from the scrum and banked it in as time expired. The call stood after a video replay, handing Texas its first win in the NCAA tournament since 2011.
Ridley finished with 17 points and 12 rebounds for the seventh-seeded Longhorns (24-10), who led by 14 with 12 minutes left. Freshman reserve Martez Walker had 16 points and Demarcus Holland scored 14 on 6-for-6 shooting from the field.
Jordan Bachynski scored 22 points for No. 10 seed Arizona State (21-12), which was making its first tournament appearance since 2009. Jahii Carson had 19 points and nine assists, and Jermaine Marshall added 17 points and seven rebounds.
Texas went to the NCAA tournament in each of Rick Barnes' first 14 seasons at the school, making it to the 2003 Final Four. But last season was a disaster for the Longhorns, who went 16-18 and lost in the opening round of the College Basketball Invitational.
Barnes lost three starters from that team, but Holmes and Ridley returned, and the Longhorns were determined to turn it around. They stumbled a bit heading into the tournament, losing five of eight, but they stepped up at the most critical time against the Sun Devils.
Holmes made two free throws to give Texas a 61-47 lead with 12:11 to go. The Sun Devils then scored 17 of the next 22 points, trimming the deficit to two on Jonathan Gilling's 3-pointer with 8:15 left.
Arizona State had an 83-82 lead when Holmes grabbed an air ball by Javan Felix and scored while being fouled by Gilling. He made the resulting foul shot with 32 seconds to go.
Gilling made two free throws on the other end, setting up the frantic finish. Gilling had four 3-pointers and 15 points for the Sun Devils, who lost their last four games of the season.
The battle of at-large teams in the Midwest Regional featured a pair of coaches with a long history. Barnes first met Herb Sendek at a 1978 basketball camp at the University of Pittsburgh, and Barnes had Sendek on his staff for one season when he was in charge at Providence. They also coached against each other for years in the Atlantic Coast Conference.
Their only other meeting in the NCAA tournament occurred in 2006, when Texas beat North Carolina State 75-54 in the round of 32.
Both teams got off to fast starts, with Bachynski's jumper for Arizona State tying it at 21 with 12:32 to go. But Texas responded with a 9-0 run, beginning with Walker's two free throws and ending with Walker's 3 from the wing.
Walker added a layup with 31 seconds left to help the Longhorns to a 41-36 halftime lead.
Texas will play No. 2 seed Michigan on Saturday.