Vance McDonald and Torrey Smith both hauled in catches in the opening drive of the game as the 49ers tried to get some early points on the board, but the visitors had to settle for a 54-yard field goal from Phil Dawson.
The 49ers got the ball back without the Rams scoring on their first possession, but running back Mike Davis was tackled in the endzone for a safety, while Reggie Bush was forced out with a knee injury.
Neither side could get a touchdown on the board in the first quarter, but St Louis struck early in the second when Gurley slipped past a couple of 49ers players before beating Eric Reid in a 71-yard race for the line.
The hosts extended their lead to 10 points shortly after through a Greg Zuerlein field goal, but Dawson added three more for the 49ers after Colin Kaepernick and the offense came up short looking for their first touchdown.
The Rams had the ball again before the break, and extended their lead further in the final seconds as Austin stretched the ball across from two yards out.