Southern California had too many penalties, struggled in the red zone and found itself in a late hole for the second straight week.
The Trojans rallied to win a week ago and did it again with another pair of late scoring drives.
Resiliency has been the theme so far for USC in this pandemic-shortened season.
Vavae Malepeai bulled his way through multiple tacklers for an 8-yard touchdown run with 25 seconds left, and No. 20 USC beat Arizona 34-30 on Saturday.
“We have some things we need to get better at, but we're 2-0,” coach Clay Helton said. “A lot of teams would like to be in that position.”
USC (2-0, 2-0 Pac-12) was outplayed by Arizona State last week before scoring two touchdowns in the final three minutes of a 28-27 victory.
The Trojans again rallied late to win a game they were outplayed in for most of the afternoon.
Slovis, off target early, completed four straight passes for 68 yards, and Malepeai capped the 75-yard drive by carrying several Arizona defenders with him into the end zone.
“At the end, our kids did what they did last week,” Helton said. “When it mattered the most, they never panicked, they showed great poise.”
Slovis threw for 325 yards and a touchdown on 30-of-43 passing. He was 11 of 12 for 158 yards on USC's final two drives.
Gunnell threw for 286 yards and three touchdowns for Arizona, which played its first game in nearly a year after last week's opener against Utah was canceled due to the coronavirus.
“There's definitely some disappointment, especially when it's that close and everyone is saying you're the underdog — literally everyone,” Gunnell said. "But we're optimistic and we're driven. That's the 20th-ranked team in the nation and our first game of the year.”
The sophomore entered the 2020 season as the starter after sharing time with Khalil Tate last year and had a streak of 92 straight passes without an interception. The streak nearly ended on his first pass against USC and then did on the second, when he overthrew a receiver into Talano Hufanga's arms.
That set up Markese Stepp's 1-yard TD run.
Gunnell was much better on the next drive, hitting Jamarye Joiner on a short pass that turned into a 34-yard touchdown.
Arizona kept churning out yards — 231 by halftime — but had to settle for three field goal attempts. Lucas Havrisik made two and USC led 17-13 at halftime after Stephen Carr scored on a 3-yard run with 2 1/2 minutes left.
Arizona tied it at 20 when Gunnell hit Tayvian Cunningham in stride for a 75-yard touchdown reception in the third quarter.
USC struggled in the red zone early in the second half.
Amon-Ra St. Brown pulled down a spectacular 48-yard catch, but the Trojans stalled and settled for Parker Lewis' 28-yard field goal. Stepp ripped off a 49-yard run on the next drive and USC marched down to Arizona's 1-yard line. Consecutive penalties back the Trojans up and Lewis pushed a 28-yard field goal wide right.
Another drive into the red zone, another trip without points. This time, Arizona stopped the Trojans on fourth-and-1 from the Wildcats 4.
Havrisik gave Arizona its first lead at 23-20 with a 51-yard field goal midway through the fourth.
“You either win or lose, but we had some experienced guys we expected to play well and obviously some newcomers, whether they were transfers or young guys that played well, but not well enough to win,” Arizona coach Kevin Sumlin said. “That's the bottom line.”
USC played undisciplined at times and was disjointed at times on offense, particularly in the red zone. The Trojans again pulled it together for a 2-0 start.
Arizona did not look rusty in its first game in nearly a year. Gunnell was sharp and the defense was solid in its first game under new coordinator Paul Rhoads before playing on its heels on the final two drives.
USC moved up a spot after its close call against Arizona State, but may drop a spot or two after going down to the wire against a team it was heavily favored against.
Last week, USC was plagued by four turnovers. Against Arizona, the Trojans struggled with penalties and capitalizing in the red zone.
USC had 11 penalties for 110 yards and twice came away with no points after reaching Arizona's 5-yard line.
“We had some opportunities to put the game away in the second half and didn't,” Helton said.
Arizona running back Gary Brightwell spent his first three seasons in Tucson as a backup before becoming the No. 1 running back this season.
The senior had a strong debut, using his speed and hard-nosed running to pick up 112 yards on 21 carries.
USC plays at Utah next Saturday.
Arizona is at Washington on Saturday.
More AP college football: http://apnews.com/Collegefootball and http://www.twitter.com/AP_Top25