GLENDALE, Ariz. — Jimmy Garoppolo threw for 317 yards and four touchdowns and the San Francisco 49ers reached 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 — 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.

NFL'S FIRST EMOTIONAL SUPPORT DOG HELPS UNDEFEATED 49ERS DURING WINNING STREAK

San Francisco 49ers quarterback Jimmy Garoppolo (10) throws against the Arizona Cardinals during the second half of an NFL football game, Thursday, Oct. 31, 2019, in Glendale, Ariz. (Associated Press)

The 49ers were in control until about five minutes left in the fourth quarter, when Andy Isabella caught a short pass and sprinted for an 88-yard touchdown 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. San Francisco's Emmanuel Sanders caught seven passes for 112 yards and a touchdown.

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

CLICK HERE TO GET THE FOX NEWS APP

The Cardinals came into the game without their top two running backs, David Johnson and Chase Edmonds, who were battling injuries.

Kenyan Drake — who was acquired by the Cardinals on Monday in a trade with the Miami Dolphins — ran for 36 yards on the first play of the game and capped the opening drive with a 4-yard touchdown run. He finished with a team-high 110 yards rushing and 52 yards receiving.