GLENDALE, Ariz. – The Cardinals had nothing going for most of the game. The team put up just three points through three quarters and trailed the 49ers 15-3 early in the fourth.

But, things turned.

After an impressive (finally) offensive drive came early in the fourth quarter highlighted by a 37-yard completion from Rosen to Larry Fitzgerald and then a touchdown pass to Fitzgerald, the Cardinals cut the lead to five.

The defense made a stop and the Cardinals got the ball back with just under 9 minutes to go in the game. The offense was driving again when Rosen found Jermaine Gresham, who took the pass for a first down and up the sideline into 49ers territory before inexplicably coughing up the ball back to San Francisco.

The Cardinals got one more crack at it after a third down sack by Budda Baker with two minutes to go forced the 49ers to punt.

Once again, Rosen and the Cardinals marched down the field. Getting the ball inside the 10-yard-line with under a minute left.

Then, on third down, Rosen found Christian Kirk in the back of the end zone, who held onto the catch after taking a big hit.

Rosen passed to Larry Fitzgerald for the two-point conversion, giving the Cardinals an 18-15 lead.

With 34 seconds to go, the Cardinals were able to stop the 49ers and held on for the win.The Cardinals now move to 2-6.

The 321 total yards for the Cardinals is the most the team has had in a game all season. Quarterbacks coach Byron Leftwich was promoted to offensive coordinator 10 days ago after the team fired Mike McCoy.

Josh Rosen finished with 252 yards through the air and two touchdowns. Larry Fitzgerald had eight catches for 102 yards and a touchdown. Christian Kirk had 42 receiving yards and a touchdown.

It's the sixth win in a row for the Cardinals against the 49ers.

Arizona is on bye next week and will play again in Kansas City against the Chiefs Nov. 11.