GLENDALE, Ariz. -- The Arizona Cardinals showed Sunday it wasn't how they started, it was how they finished.

In Byron Leftwich's first game as interim offensive coordinator, the Cardinals' offense showed signs of evolution throughout the first three quarters but lacked in production. They scored just three points heading into the fourth.

Then, with a seventh loss minutes away, the offense produced. A lot.

In his first game as offensive coordinator, Byron Leftwich directed the Cardinals to their first 300-yard game of the season. Norm Hall/Getty Images

Rookie quarterback Josh Rosen led Arizona on a 73-yard drive that ended with a 9-yard touchdown pass to rookie receiver Christian Kirk with 34 seconds left to give Arizona an 18-15 win over the San Francisco 49ers as the Cards head into their bye week.

"We were a little inconsistent at times but when we needed it in the end, we showed up, particularly on the offensive side of the ball," coach Steve Wilks said.

Wilks was pleased with Leftwich's first game calling plays, which produced Arizona's first 300-yard game of the season.

"Byron had us into a rhythm," Wilks said. "As you can see, the operations were great from a standpoint of just getting a play in, being able to get to the line of scrimmage and [identifying] the defense and linebacker was outstanding."

Rosen called Leftwich a "steadying force" for the offense.

When Leftwich was promoted to offensive coordinator on Oct. 19 following Mike McCoy's firing, his focus was two-fold: Get David Johnson involved more and resuscitate Larry Fitzgerald's season.

Both happened Sunday, albeit not to the standard that the Cardinals need to turn this year around.

Larry Fitzgerald celebrates after scoring a 2-point conversion with less than a minute to play on Sunday. Joe Camporeale/USA TODAY Sports

Leftwich said on Thursday he didn't think Fitzgerald was "dead yet." And Rosen relied on Fitzgerald on that final drive, hitting him twice for 31 yards, including a 20-yard pass that moved Arizona into San Francisco's side of the field. Rosen then hit Fitzgerald on the two-point conversion that gave the Cardinals a three-point lead.

Fitzgerald had eight catches for 102 yards and a touchdown -- his first 100-yard game of the season.

"We all know what he is, a first-ballot Hall of Famer for that mere reason what you saw tonight," Wilks said.

While Fitzgerald was seemingly revived, Leftwich also found a way to get Johnson involved in different ways, not necessarily more ways.

NFL scores, standings and more Everything you need this week:

• 2018 playoffs coverage »

• Full schedule » | Full standings »

• 2019 draft order: Every first-round pick »

More NFL coverage »

Leftwich knew it was going to be "tough to change a lot in a week." But he was able to change just enough.

Even though the Cardinals' offense mustered just three points in the first three quarters and looked as out of sorts as it has all season, it showed signs of renewed ingenuity. Leftwich got Johnson, who left the game in the fourth quarter to be evaluated for a concussion but eventually returned and is "fine," Wilks said, involved in the screen game. Twenty-seven of Johnson's 41 receiving yards -- his best receiving day of the season -- came from the screen game. Johnson complemented that with 59 rushing yards on 16 carries, giving him 100 all-purpose yards -- the second time this season he has reached 100 yards from scrimmage.

"I liked the way we used David tonight in a number of ways -- in the screen game and getting him out to the perimeter," Wilks said. "Byron did a great job of just trying to utilize his talents."

When Rosen, who said the first three quarters were "frustrating," stepped into the huddle with 2:16 left in the game, he reassured the offense it was going to march down the field and win the game with one simple sentence: "We're about to win the f---ing game."

Then he did it.

"Josh is unfazed," tight end Jermaine Gresham said. "He played a hell of a game today. He grew up so much today in this game and just made it through so much tough times."