PASADENA, Calif. (AP) Stanford coach David Shaw is the first to admit that he hasn't been comfortable with his team all season. But as long as they keep winning, it doesn't matter to him.
The Cardinal once again got big plays from their passing game as they rallied for a 49-42 victory over UCLA on Saturday.
Stanford had nine pass plays of 15 or more yards with four resulting in touchdowns. K.J. Costello completed 23 of 37 for 344 yards and a career high five touchdowns as they extended their winning streak over the Bruins to 11 games.
''I've learned a lot this year. Apparently my comfort level doesn't matter,'' Shaw said. ''We've been an enigma but the one thing that has been consistent are the big plays in our passing game. Hopefully they continue to happen and we'll grow in the running game.''
The Cardinal (7-4, 5-3 Pac-12) trailed 42-41 midway through the fourth quarter when the junior threw a 52-yard touchdown pass to Osiris St. Brown. Bryce Love ran it in for the two-point conversion to put them up by a touchdown.
UCLA (3-9, 3-6) drove to the Stanford 43 with under a minute remaining before turning it over on downs.
JJ Arcega-Whiteside - who had seven receptions for 106 yards - caught three touchdowns. He has 14, which ties the school's single-season record first set by James Lofton in 1978. Trenton Irvin (seven receptions, 103 yards) also had a touchdown while Love rushed for 85 yards on 22 carries with a TD.
''Really you pick your poison out there,'' said Costello about the options on offense. ''We take what the defense gives us and we did that real well today.''
UCLA's Wilton Speight was 29 of 47 for 466 yards and an interception and one rushing touchdown in his final collegiate game. Tight end Caleb Wilson was his main target with nine receptions for 184 yards.
Joshua Kelley rushed for 55 yards on 18 carries with two touchdowns and Martell Irby had 47 yards and a score.
UCLA trailed 41-27 with 5:24 remaining on an Arcega-Whiteside TD from Costello before beginning its rally. UCLA got its first safety since 2012 when Martin Andrus tackled Love in the end zone. On the free kick, Darnay Holmes returned it 93 yards to bring the Bruins within 41-36 with 2:09 left in the third.
After a Stanford punt, the Bruins took a one-point lead on a 13-play, 90-yard drive, culminating in a Speight keeper from a yard out.
''We had our opportunities today but we just didn't capitalize,'' UCLA coach Chip Kelly said.
WINNING DRIVE EXPLAINED
Shaw said he texted St. Brown after his younger brother, USC freshman Amon-Ra St. Brown, caught a 44-yard touchdown in the first quarter last week against the Bruins and said they were going to run the same exact play.
Stanford called two running plays, which netted 23 yards for Cameron Scarlett, before the play action to St. Brown.
''When you give up a big play run it twice so the offensive line can get physical and then come back with play action. It worked to perfection,'' Shaw said. "It was man coverage with no help in the middle. It was a great job by K.J. sliding in the pocket and buying time.''
The game drew only 38,391 to the Rose Bowl, which marks the lowest UCLA home crowd since 1997 when 38,165 saw the Bruins face Oregon State.
Stanford: The Cardinal had allowed only one touchdown in the third quarter this season until Saturday, when they allowed two touchdowns and a safety.
UCLA: Chip Kelly will be looking to upgrade his defense after the Bruins allowed 40 or more points in four games this season. UCLA lost its first five games but showed some signs of improvement over the second half.
Stanford: Faces Cal in Berkley next Saturday after wildfires postponed the Nov. 17 game.
UCLA: Opens the 2019 season on Aug. 31 at Cincinnati.