The Arizona Cardinals improved to 5-0 for the first time since 1974, riding a stellar defensive performance to a 17-10 win over the San Francisco 49ers on Sunday.

DeAndre Hopkins hauled in a difficult 9-yard touchdown catch with 5:13 remaining, hanging onto the football despite tight defense from San Francisco's Josh Norman. That gave the Cardinals a 17-7 lead, enough of a cushion to close out the win.

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

Kyler Murray completed 22 of 31 passes for 239 yards. Hopkins caught six passes for 87 yards.

Niners rookie quarterback Trey Lance had an up-and-down first start, making some impressive plays with his arm and feet. But the San Francisco offense struggled in many of the biggest moments, converting 1 of 5 chances on fourth down.

Lance finished 15 of 29 passing for 192 yards and one interception. He also led the team with 89 yards rushing.

The Cardinals settled for a 10-0 halftime lead after Matt Prater missed a 61-yard field goal attempt as time expired. The 49ers (2-3) did a good job of slowing Arizona’s offense, which came in averaging an NFL-best 35 points per game.

The 49ers finally broke through on offense late in the third quarter when Deebo Samuel ran 13 yards for a touchdown, cutting the deficit to 10-7. Samuel came in as the NFL's leading receiver and also proved a capable runner, taking the pitch from Lance and evading several Cardinals on the way to the end zone.

San Francisco had a few more chances in the fourth quarter but couldn't convert on fourth downs. Kyle Juszczyk was stopped short on fourth-and-1 at the Cardinals 48 and Arizona defensive lineman J.J. Watt deflected a fourth-down pass a few minutes later.

Arizona, the NFL's only remaining undefeated team, grabbed a 7-0 lead midway through the first quarter thanks to an efficient eight-play, 66-yard drive capped by a 1-yard touchdown run by James Conner.

Lance was making his first career start in place of the injured Jimmy Garoppolo, inactive for the game because of a calf injury suffered in last week's loss to Seattle. The 21-year-old rookie had a rough start, throwing an interception after sailing a pass past his intended receiver and right into the arms of Arizona safety Budda Baker. He was also stopped on two fourth-down runs, including one inches shy of a touchdown.

On that play, Lance scrambled to his right and looked like he was going to score, but Isaiah Simmons and Tanner Vallejo closed quickly, meeting the quarterback just before the goal line in a violent collision. Simmons was evaluated for a concussion after the play, but later returned to the game.

CLICK HERE TO GET THE FOX NEWS APP

WATT'S PRESENCE

Watt had his best game with the Cardinals, coming up with the big pass deflection in the fourth quarter and also getting his first tackle for a loss, stopping Elijah Mitchell for a 3-yard loss in the first quarter.

The three-time NFL Defensive Player of the Year has had a relatively slow start this season from a numbers standpoint. Even so, defensive coordinator Vance Joseph has been pleased with how much attention Watt draws from opposing blockers, making it easier for other on the defense to make plays.

INJURIES

Cardinals: Cornerbacks Byron Murphy Jr. and rookie Marco Wilson were both inactive because of rib injuries. ... TE Maxx Williams was carted off the field in the second quarter after a knee injury. Williams caught a 14-yard pass and then his knee appeared to buckle as he ran out of bounds. ... LB Ezekiel Turner (shoulder) and C Rodney Hudson (ribs) left in the third quarter.

UP NEXT

The 49ers are off next weekend before hosting the Indianapolis Colts on Oct. 24.

The Cardinals travel to face the Cleveland Browns next Sunday.