The Niners (4-5) had lost four of five games and were in danger of falling out of the playoff race before putting together a complete performance against the Rams (7-3). San Francisco has won five straight against Los Angeles.
Garoppolo threw TD passes to George Kittle and Deebo Samuel, Samuel also ran for a score and Ward delivered the big plays defensively to give San Francisco its second home win in the past two seasons. The other also came against the Rams on Oct. 18, 2020.
The Niners sealed the game when Garoppolo connected on a 40-yard TD to Samuel on fourth-and-6 early in the fourth quarter that made it 31-7.
Garoppolo finished 15 for 19 for 182 yards and the two TDs.
The Rams lost for the second straight week with Matthew Stafford once again throwing two interceptions, including one returned for a touchdown.
Los Angeles struggled to get into any rhythm offensively in the first game after receiver Robert Woods went down with a season-ending knee injury last week in practice.
Odell Beckham Jr. made his Los Angeles debut after signing last week but had only two catches for 18 yards.
Recently acquired edge rusher Von Miller also played for the first time with the Rams and had three tackles but didn't put pressure on Garoppolo.
Stafford went 26 for 41 for 243 yards with one TD, two interceptions and nearly a third that K'Waun Williams trapped on his backside only to have it wiped off by a penalty.
TAKE IT AWAY
Ward intercepted Stafford on Los Angeles' first two drives of the game after coming into the night with two INTs in 85 games and none since 2016.
The first came on a deep heave by Stafford to Beckham that went right to Ward. The next came on a quick throw that tight end Tyler Higbee bobbled right into Ward's hands, leading to a 27-yard TD return.
Ward became the seventh player since 2000 with two interceptions, including a pick-6, in the first quarter.
KEEP IT AWAY
The Niners did a good job keeping the ball away from Stafford in the first half. They had an 18-play, 93-yard drive that took 11:03 off the clock after Ward's first interception. It was capped by an 8-yard TD pass from Garoppolo to Kittle.
That was the second opening drive of at least 18 plays in the past eight seasons, with Houston doing it earlier this year against New England.
San Francisco then had an 11-play, 91-yard drive on it second possession capped by Samuel's 8-yard run to take a 21-7 lead.
Rams coach Sean McVay made a curious decision when he called for a fake field goal on fourth-and-8 from the 17 with 18 seconds left in the first half.
Holder Johnny Hekker completed a 2-yard pass to Kendall Blanton that was well short of the first down.
Rams: RB Darrell Henderson left in first quarter to be evaluated for a concussion but returned late in the first half.
49ers: RT Jaylon Moore (knee) left the game in the first half.
Rams: Los Angeles has a bye next week before visiting Green Bay on Nov. 28
49ers: Visit Jacksonville on Sunday.