GLENDALE, Ariz. — GLENDALE, Ariz. (AP) — Jimmy Garoppolo threw for 317 yards and four touchdowns and the San Francisco 49ers reach the halfway point of their season undefeated, beating the Arizona Cardinals 28-25 on Thursday night.

San Francisco (8-0) fell behind 7-0, but responded with three touchdowns — including one as time expired in the second quarter after Cardinals coach Kliff Kingsbury called a timeout and gave the 49ers a second chance on fourth down — to take a 21-7 halftime lead.

The 49ers were in control until about five minutes left in the fourth quarter, when Andy Isabella caught a short pass and sprinted 88 yards to help the Cardinals pull to 28-25.

But the 49ers were able to run out the clock on their ensuing offensive drive to end Arizona's comeback.

Arizona (3-5-1) lost its second straight game. Rookie quarterback Kyler Murray threw for 241 yards and two touchdowns.