SANTA CLARA, Calif. (AP) Josh Rosen hit San Francisco with a deep strike on his first snap and let Arizona's opportunistic defense take over from there.

That formula added up to the long-awaited first win of the season for the Cardinals.

Rosen threw a 75-yard touchdown pass to fellow rookie Christian Kirk on Arizona's first play from scrimmage and the Cardinals used five takeaways to give first-year coach Steve Wilks his first career win , 28-18 over the 49ers on Sunday.

''There's no such thing as an ugly win in the National Football League, particularly when it's your first one,'' Wilks said.

If any qualified, this might be it. The Cardinals (1-4) averaged just 3 yards per play after the opening snap, with their only other scores coming on Josh Bynes' fumble return for a TD and David Johnson TD runs on two short drives after turnovers by the 49ers (1-4).

The Niners had the decided edge in yardage (447-220), first downs (33-10) and offensive plays (92-49), but Arizona's defense delivered in key moments with two interceptions and three fumble recoveries.

''It shows how mentally tough we truly are,'' said safety Tre Boston, who had an interception. ''An 0-4 team if you're not mentally tough and you don't believe in your process, you lose that game right there. You see yourself in the same predicament you've been in and you see yourself losing. That's not us. We saw ourselves winning.''

Niners backup quarterback C.J. Beathard completed all five passes on the opening drive - four of which were behind the line - and gave San Francisco a 6-0 lead on a 5-yard shovel pass to Matt Breida. The Niners botched the extra point and were trailing for good 10 seconds later on a day when the offense struggled to finish.

''You look at a lot of those (stats), it's hard to find how you lost a game,'' coach Kyle Shanahan said. ''Then it's very easy when you look at the turnover column. I haven't been part of any game, I don't think many people have, where five turnovers to zero leads to a win. We have to improve that drastically to have a chance.''

Rosen dropped back and launched a deep throw to Kirk, who was wide open down the middle of the field because free safety Adrian Colbert jumped up to try to take away Larry Fitzgerald on the play.

It was the perfect start for a team that scored just 37 points the first four games.

''We were just trying to get a spark in any way possible and just try to get our offense going,'' Rosen said. ''We haven't been scoring as many points as we wanted to. I think we took a really good first step.''

Patrick Peterson recovered a fumble by Raheem Mostert and returned it 49 yards to the San Francisco 18, setting up Johnson's 2-yard run that made it 14-6.

The Niners finally scored again on a fourth-and-1 pass from Beathard to Trent Taylor with 6:51 to play. But San Francisco couldn't convert the 2-point try and fell to 1-12 over the past two seasons without Jimmy Garoppolo as starting quarterback.

The Cardinals sealed the game when Haason Reddick knocked the ball out of Beathard's hand and Bynes returned it for a 23-yard score that gave Arizona its seventh straight win in the series.

Rosen got the win in his second start of the season despite completing just 10 of 25 passes for 170 yards. The one big play proved to be enough to beat the Niners.

''It's frustrating,'' cornerback Richard Sherman said. ''Obviously the first play of the game on defense, we give up a big play. We just have to be better than that. It was a simple play, it was easy to get stopped and we just didn't execute it like we needed to. So, that's where you need to because after that they didn't have much.''

CHANDLER'S DAY

Arizona defensive end Chandler Jones had a dominant day. He had a strip sack and fumble recovery against Beathard in the third quarter, and then batted away the 2-point conversion pass to Pierre Garcon with 6:51 to play to preserve a 14-12 lead.

BROKEN STREAK

Robbie Gould had made a franchise-record 33 straight field goals for the 49ers before missing wide right from 45 yards in the fourth quarter. The 49ers also botched an extra point in the first quarter when Gould didn't even get an attempt.

INJURIES

Cardinals: OL Andre Smith left in the second half with a hamstring injury.

49ers: Breida left in the first quarter with an injured right ankle and didn't return. Breida entered the week fourth in the league in rushing with 313 yards and had eight carries for 56 yards, along with his TD catch before the injury. ... C Weston Richburg left in the second half with a knee injury.

UP NEXT

Cardinals: Visit Minnesota next Sunday.

49ers: Visit Green Bay on Oct. 15.

---

More AP NFL: https://apnews.com/tag/NFL and https://twitter.com/AP-NFL

Copyright 2018 by AP. Any commercial use or distribution without the express written consent of AP is strictly prohibited.