(TSX / STATS) — Linebacker Austin Calitro forced a fumble in the fourth quarter, setting up the winning touchdown drive for the San Francisco 49ers in their 27-17 preseason victory over the Kansas City Chiefs on Friday night at Arrowhead Stadium in Kansas City, Mo.

Calitro, signed four days ago after Malcolm Smith suffered a season-ending torn pectoral muscle, delivered a hit on Chiefs rookie receiver Marcus Kemp to force the turnover with 13:09 remaining in the fourth quarter. Defensive back D.J. Jones recovered the loose ball.

Rookie quarterback C.J. Beathard led a five-play, 23-yard drive after the turnover, finding fullback Tyler McCloskey for a 2-yard touchdown pass to put the 49ers up 24-17.

Beathard, who rallied the 49ers from a 17-9 deficit, finished his professional debut 7-of-11 passing for 101 yards and two touchdowns.

Quarterback Alex Smith delivered a quick start for the Chiefs, marching the team downfield on an eight-play, 75-yard drive in his only series.

A 32-yard connection to Tyreek Hill down the right sideline set up the Chiefs on the opening play of the game. Spencer Ware finished the drive with a 2-yard touchdown run.

The 49ers’ first-team offense struggled behind starting quarterback Brian Hoyer, mustering just 3 yards in two drives. Hoyer finished 1-of-4 passing for 3 yards.

Veteran quarterback Matt Barkley, however, found more success. He led two scoring drives ending in field goals to put San Francisco up 9-7 at halftime. Barkley finished 10 of 17 for 168 yards.

Kansas City’s own rookie quarterback, Patrick Mahomes, helped jump-start the Chiefs’ offense in the second half, leading a six-play, 36-yard drive ending with a Sam Ficken field goal with 10:30 remaining in the third quarter to put the Chiefs up 10-7.

After a blocked punt by Chiefs linebacker Kevin Pierre-Louis, Mahomes connected with Kemp on a 1-yard touchdown pass, making it 17-9. Mahomes finished 7 of 9 for 49 yards and a touchdown.

Penalties marred much of the game with the teams combining for 28 flags for 199 penalty yards.

Flags erased two big offensive plays for the Chiefs. Backup quarterback Tyler Bray connected with receiver Chris Conley for an 83-yard touchdown. Offensive pass interference on Conley negated the play.

Mahomes also fired deep on his first NFL play, finding receiver Demarcus Robinson for 41 yards. A holding penalty on backup tackle Isaiah Battle washed away the big gain.