The Bruins fell behind 44-10 in the third quarter before four Josh Rosen touchdown passes -- all in the fourth quarter -- and a Soso Jamabo scoring rush brought UCLA back.
The Rose Bowl audience of 64,635 erupted on Rosen's fourth and final scoring pass, a 10-yard strike to Jordan Lasley with 43 seconds to play.
On the winning score, Rosen faked a spike before connecting with Lasley, who made an over-the-shoulder catch in the back left corner of the end zone.
The UCLA quarterback hooked up twice with Darren Andrews for scores of 9 and 42 yards, and once with Theo Howard on a 16-yarder.
The rally outpaced UCLA's previous biggest comeback by two full touchdowns. In 2005, the Bruins erased a 22-0 deficit against Northwestern.
UCLA's rally was just four points shy of matching the greatest comeback in FBS history, a 38-point rally by Michigan State against Northwestern in 2006.
Rosen went 35 of 58 for 471 yards for the Bruins, who trailed 44-17 entering the final quarter. It was his first appearance since sustaining a shoulder injury that cost him the second half of the 2016 season.
Rosen and the rest of the UCLA struggled mightily early. Texas A&M deployed an aggressive pass rush, exploiting the Bruins' inability to mount a consistent run game.
UCLA endured a six-possession stretch with two fumbles, four punts and not a single first down. The Aggies capitalized with a multi-faceted rushing attack, led by running backs Trayveon Williams and Keith Ford. The duo combined for 317 of Texas A&M's 382 rushing yards and scored all five of the team's touchdowns.
The last of those TDs came just before halftime when Williams went 61 yards to make it 38-10. That score one play after Jalen Starks scored the lone UCLA touchdown of the first half on a 2-yard rush, set up by a 57-yard pass from Rosen to Lasley.