GLENDALE, Ariz. -- The 49ers needed a win in the worst way. Instead, they got a loss -- in the worst possible way.
The 49ers’ offense struggled for most of the game, and the defense sustained a couple of injuries to key players, as San Francisco's skid hit six games with a 18-15 loss to the Arizona Cardinals on Sunday.
The 49ers fell to 1-7 and sit all alone in the cellar of the NFC West, while the Cardinals improved to 2-6 with their second victory over the 49ers in four weeks.
Arizona rookie quarterback Josh Rosen hit Christian Kirk with a 9-yard touchdown pass with 34 seconds remaining to enable the Cardinals to rally from a 12-point fourth-quarter deficit for the win.
The game was the first of three consecutive matchups for the 49ers against teams that entered Week 8 with only one win. They return to action Thursday night against the Raiders before facing the New York Giants in Week 10 on Monday Night Football.
Here are three quick takeaways from the 49ers’ win over the hapless Cardinals:
Taking care of the ball
It was far from a masterpiece for the 49ers. But it was a marked improvement over the last time the teams met, just three weeks ago at Levi’s Stadium in Santa Clara.
On that day, the 49ers dominated the Cardinals in every statistical category, except turnovers. And with a minus-five turnover margin, the 49ers were 28-18 losers to the previously winless Cardinals.
On Sunday, the 49ers had several near-misses. C.J. Beathard had a pass batted in the air at the line of scrimmage that dropped to the ground. And rookie Dante Pettis muffed a punt return with the ball hitting him in the face. But teammate Elijah Lee was there for the recovery.
In the second quarter, the 49ers snapped a streak in which they committed 15 consecutive giveaways without a takeaway when safety Jaquiski Tartt came up with the team’s second interception of the season.
Defense is the best offense
While the 49ers’ offense struggled out of the gate Sunday, the defense was the lone bright spot as the team took a 5-3 lead in the second quarter.
The 49ers even broke a streak of 16 consecutive quarters without generating a takeaway, when Tartt intercepted Josh Rosen’s pass over the middle intended for rookie receiver Christian Kirk in the second quarter.
Tartt returned the interception 23 yards to the Arizona 12. After three unsuccessful offensive plays, kicker Robbie Gould made a 27-yard field goal.
The 49ers scored first when defensive end Cassius Marsh wrapped up Cardinals quarterback Josh Rosen in the end zone. Rosen tried to throw the ball away but was called for intentional grounding and a safety.
Another defensive highlight of the first half came when Richard Sherman came off the left corner to record a sack. It was just the second sack of his eight-year NFL career, and the first since his second NFL season of 2012.
Beathard’s first-half struggles
The 49ers’ offense was a hot, stinking mess in the first half while the defense played well.
Beathard and Co. again looked completely overmatched. Through the first 30 minutes, Beathard completed just four of nine pass attempts for 39 yards. He was sacked three times for minus-22 yards.
Tight end George Kittle and fullback Kyle Juszczyk were called for false starts. Wide receiver Kendrick Bourne, who started in place of injured Pierre Garçon, seemed to have difficulty on multiple occasions figuring out where to line up after breaking the huddle. The 49ers twice called timeouts to avoid delay penalties.
The second half didn't begin much better, either, but wide receiver Marquise Goodwin’s big-play ability provided a big boost in the third quarter. Goodwin caught a shallow crossing route against Cardinals cornerback Patrick Peterson and turned it into a 55-yard touchdown. The play provided the 49ers with a 12-3 lead.
Beathard finished the game -- his ninth loss in 10 career starts -- completing 14 of 28 passes for 190 yards and one touchdown with no interceptions for a passer rating of 83.9.