SANTA CLARA, Calif. (AP) The San Francisco 49ers gave away everything but the game.

Jimmy Garoppolo threw a 5-yard touchdown pass to Dante Pettis with 1:15 remaining and the 49ers overcame five turnovers to beat the Pittsburgh Steelers 24-20 on Sunday for their first 3-0 start in 21 years.

''It's never perfect,'' cornerback Richard Sherman said. ''We didn't play perfect today but our record is perfect.''

The Niners gave the ball away four times in the first half and then lost a fumble again in the fourth quarter, but still managed to pull out the victory and spoil Mason Rudolph's first career start in place of the injured Ben Roethlisberger for the Steelers (0-3).

A team that won just 10 games combined in coach Kyle Shanahan's first two seasons heads into a week off in good shape after surviving the home opener.

''It's a good start,'' Garoppolo said. ''There's a lot of football left. Three wins won't get you anything in this league.''

Rudolph threw two long touchdown passes in the second half, connecting on a 76-yarder to JuJu Smith-Schuster and a 39-yarder to Diontae Johnson that gave the Steelers a 20-17 lead in the fourth quarter.

The Niners answered the first strike with a 75-yard touchdown drive capped by a 4-yard run by Jeff Wilson Jr. and appeared poised to do the same when they drove inside the 10 following the second score.

But on third down from the 7, a shotgun snap hit receiver Richie James Jr. as he went in motion and T.J. Watt recovered the fumble for Pittsburgh on San Francisco's third red-zone turnover of the game.

The Steelers then gave it right back when James Conner was stripped by Arik Armstead and DeForest Buckner recovered at the 24. After a third-down holding penalty on Mark Barron extended the drive, Garoppolo found Pettis for the go-ahead score.

Pettis had caught just four passes for 22 yards this season before the TD grab, but made the biggest play yet for San Francisco.

''There obviously have been a lot of ups and downs,'' he said. ''You're not just going to be good every single day. Now that I know what it's like to go through that, I know I can do this. I know I'm here for a reason.''

Pittsburgh was unable to generate a first down on the ensuing drive with Rudolph taking a sack on third down and throwing an incompletion on fourth to send the Steelers to their second 0-3 start since 2000.

''We get ready for next week,'' coach Mike Tomlin said. ''It's as simple as that. That's life in the National Football League. It'd be the same had we won. We're not into the keep it together discussions. That's not how we're built.''

Garoppolo finished 22 for 32 for 277 yards. He threw two interceptions on the first three drives on passes that hit his receivers' hands and also lost a fumble on a bad snap from center by Weston Richburg with the Niners inside the Pittsburgh 10.

Rudolph finished 14 for 27 for 174 yards, throwing an interception to K'Waun Williams on the opening drive of the second half to set up Wilson's first touchdown.

INJURIES

Steelers: TE Vance McDonald left the game in the first half with a shoulder injury.

49ers: CB Ahkello Witherspoon left in the second half with a foot injury that he doesn't believe is serious.

IMPRESSIVE DEBUT

Steelers safety Minkah Fitzpatrick made a big impact in his first game since being acquired from Miami this past week in a deal that sent a first-round pick to the Dolphins. He intercepted a pass in the first quarter and then forced a fumble by Raheem Mostert in the red zone in the second quarter that Devin Bush recovered. He became the first Steelers player with an interception and forced fumble in the opening half since James Harrison did it against the Chargers on Nov. 16, 2008.

ROUGH DEBUT

Cornerback Jason Verrett made his debut for the 49ers and was picked on after Witherspoon left with the injury. He committed a 32-yard pass interference penalty and then was beaten deep by Johnson on a 39-yard score the following play to give the Steelers a 20-17 lead in the fourth quarter.

MISSED OPPORTUNITIES

The first two turnovers by San Francisco gave the Steelers the ball in scoring position but they were unable to generate a first down on either drive and settled for field goals. Rudolph completed three passes for only 5 yards the first possession, leading to a 46-yard field goal by Chris Boswell. Rudolph then threw an incomplete pass on third-and-5 following two runs by James Conner, leading to a 26-yard field goal.

UP NEXT

Steelers: Host Cincinnati on Monday night.

49ers: After a week off, the Niners host Cleveland on Oct. 7.

---

More AP NFL: https://apnews.com/NFL and https://twitter.com/AP-NFL

Copyright 2019 by STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.