The Rams trailed from the outset after quarterback Matthew Stafford threw an interception on the opening drive, and the 49ers converted it into a touchdown.
With the loss, Sean McVay fell to 6-18 when trailing at halftime since he was named Rams coach in 2017.
"This was a humbling night for us as a team," McVay said after the game.
The Rams (7-3) enter their bye week on a two-game losing streak with a multitude of problems to correct in a season rich with Super Bowl expectations.
"We'll look inwardly, we're going to figure this thing out," McVay said, "and we're going to come back freaking swinging, I promise you that these last seven games of the regular season."
QB breakdown: For a second consecutive game, Stafford threw back-to-back interceptions, including a pick-six, in the first quarter. Both turnovers were converted into touchdowns to give the 49ers a quick 14-0 lead.
"Put us behind the eight-ball early, and playing against a team that can control the clock, control the ball the way they can, it's not the way you want to play those guys from behind early on," Stafford said.
Stafford also dealt with a multitude of uncharacteristic mistakes from his typically sure-handed targets as the offense navigated its first game without receiver Robert Woods, who is out for the season after tearing the ACL in his left knee in practice.
Through three quarters, the Rams had three drops, matching their season high, with all three drops on third down. By the fourth quarter, they were up to five drops, their most in a game since 2013.
Stafford finished 26-of-41 for 243 yards and a touchdown with two interceptions.
Five of Stafford's eight interceptions this season have occurred in prime-time games, and he leads the NFL in prime-time picks this season. Stafford-led teams have now lost 33 straight games when trailing by 14 or more points, including three losses this season.
However, it quickly became apparent that despite boasting a plethora of talent -- from Miller to three-time NFL Defensive Player of the Year Aaron Donald, former first-round pick Leonard Floyd and All-Pro cornerback Jalen Ramsey -- the entire defense was not prepared for the 49ers physical play as Shanahan’s game plan called to run the ball non-stop before receiver Deebo Samuel continued his seasons-long destruction of his division foe, gaining 133 all-purpose yards. The 49ers finished with 156 rushing yards, the second-most allowed by the Rams this season.
"It's definitely not fun losing but I had fun tonight," Miller said. "We didn't have too many [pass] rushes, but the ones that we did have, the two or three that we did have, I'm excited to play with 99. I'm excited about this rush, I'm excited about our defense."
The 49ers became the first team since the 2018 Indianapolis Colts to open a game with two 90-yard touchdown drives and, with the inability of the Rams defense to get off the field, the 49ers dominated the time of possession, 39:03 to 20:57.
Beckham watch: Odell Beckham Jr. agreed to terms on a free-agent deal with the Rams on Thursday, and four days later, the three-time Pro Bowl receiver was in the starting lineup. Stafford’s first pass of the game went to Beckham for a 5-yard completion, but three plays later, the novelty of their relationship was apparent as Stafford bought time to target Beckham downfield, only for Beckham to break off the route causing Stafford’s throw to be picked off in double coverage by safety Jimmie Ward.
"I was excited, felt like I was ready for the moment," Beckham said. "I feel like I've been through so much and God has put me in this position for that exact moment and it just wasn't our night. There's really no way around it. It wasn't our night, all three phases of the game."
Beckham was targeted three times and caught two passes for 18 yards.