GLENDALE, Ariz. -- Rookie Josh Rosen came into the huddle to start Arizona's final drive with a few choice words.
"We're going to win this (expletive) game," he said.
And the Cardinals did just that.
Rosen threw a 9-yard touchdown pass to fellow rookie Christian Kirk with 34 seconds to play to rally the Arizona Cardinals to an 18-15 victory over the San Francisco 49ers on Sunday in a matchup of teams with two of the worst records in the NFL.
"That was a lot of fun," Rosen said. "That's why sports are fun."
The Cardinals, winners at home for the first time under first-year coach Steve Wilks, beat San Francisco for the eighth straight time and second time in three weeks.
"Our defense gave us a very good chance to win that, giving us three turnovers and getting us a 12-point lead," San Francisco coach Kyle Shanahan said. "We didn't capitalize on them enough for touchdowns and we didn't make the plays at the end when we needed to."
Arizona (2-6) got two fourth-quarter touchdown passes from Rosen after the 49ers (1-7) had built a 15-3 lead.
Rosen's 13-yard pass to Larry Fitzgerald cut the lead to 15-10 with 11:06 to play. Fitzgerald also caught a 2-point conversion pass after Kirk's TD.
Fitzgerald, in his 15th NFL season, caught eight passes for 102 yards, his best game of the season. He had four catches for 81 yards in the fourth quarter and the crowd chanted "LAR-RY, LAR-RY."
"I threw him the ball and he caught it, whether it was a good ball or a bad ball," Rosen said. "That's why he's a first-ballot Hall of Famer. I'm going to be telling my kids one day that I got to throw to him."
Fitzgerald even spiked the football after the 2-point catch, something he said he'd never done before.
"We don't spike the ball in our house," Wilks said, "but I'll let that one slide. I think he got carried away."
Fitzgerald joked that he'd been upset because his oldest son had chosen to go to the state fair instead of the game.
San Francisco was slogging along with a 5-3 lead before Goodwin beat Patrick Peterson and took a short pass over the middle, then raced to the end zone to make it 12-3 in the third quarter. Robbie Gould's second field goal of the game, from 20 yards, boosted the lead to 15-3.
San Francisco appeared to get a critical turnover with 4:44 to play, needing a coach's challenge to get it. Arizona tight end Jermaine Gresham fumbled along the sideline and the 49ers' Fred Warner recovered at the San Francisco 31. Officials initially ruled a 49er touched the ball while out of bounds, but the 49ers challenged and replays showed the player tried but failed to touch it.
But the Niners couldn't move the ball and Arizona went 73 yards in 12 plays for the winning score, using 1:42.
The two TD drives came under the direction of new offensive coordinator Byron Leftwich, who was promoted from quarterbacks coach after Mike McCoy was fired.
"We really didn't change much in the offense," Rosen said. "One thing I think Byron's really good with is just his demeanor. ... He's got really good timing with a lot of his play calls. He's got that poise. He's a steadying force. It wasn't a pretty one by any means, but baby steps here."
San Francisco scored first when, backed up deep in Arizona territory, Rosen was called for intentional grounding in the end zone. The resulting safety made it 2-0.
The only real scoring drive of the first half resulted in Dawson's 31-yard field goal that put Arizona up 3-2. The 12-play, 78-yard drive was kept alive by a third-down pass interference penalty on Reuben Foster.
The only turnover of the first half set up San Francisco's go-ahead field goal. Jaquiski Tartt stepped in front of intended receiver Kirk and intercepted Rosen's pass, returning it 21 yards to the Cardinals 12. But the 49ers couldn't move the ball and Gould's 27-yard field goal put San Francisco ahead 5-3.
FITZ HITS 112
Fitzgerald's 112th career touchdown catch moves him past Tony Gonzalez alone into seventh on the NFL career list. He's caught a TD pass in each of his last two games after getting none the first six games of the season. He needs three to tie Antonio Gates for sixth.
The already beat-up 49ers lost two important defensive players.
Foster left early with a hamstring injury. Tartt was knocked out with a shoulder injury.
49ers defensive back Amare Exum Jr. left in the fourth quarter with a head injury.
49ers: host Oakland on Thursday night.
Cardinals: have bye week, play at Kansas City on Nov. 11.
More AP NFL: https://apnews.com/tag/NFL and https://twitter.com/AP-NFL
Chargers DB Derwin James dominated in high school... as a WR
Chargers safety Derwin James proves he's not only a great defensive back, but also a wide receiver.
Former Eagles running back/kick returner Timmy Brown dies at 82
Timmy Brown, a running back and kick returner who won an NFL championship with the Philadelphia Eagles in 1960, died Saturday. He was 82.
Justin Herbert takes out his rage by smashing things
Former Oregon QB Justin Herbert had a lot of pent-up energy when he visited with Sam Alipour for a recent Hang Time at a rage room.
Kliff Kingsbury: Arizona Cardinals' trade for DeAndre Hopkins will be official by draft
Cardinals coach Kliff Kingsbury said Tuesday that he has no doubt the trade that landed wide receiver DeAndre Hopkins from the Texans in return for running back David Johnson will be completed before the NFL draft begins on April 23.
Ron Rivera: Would only deal No. 2 pick if a 'high impact' player is available with return in trade
Coach Ron Rivera said Tuesday the Redskins need an impact player with the No. 2 pick, whether they draft someone with the selection or trade back.
Falcons GM confident Todd Gurley's knee will stand up to scrutiny of physical
Falcons general manager Thomas Dimitroff stood firm Tuesday when pressed on the team's confidence in Todd Gurley's knee.