Rice ran 11 yards for a touchdown on a reverse Sunday and the 49ers moved into a first-place tie with the Rams in the NFC West by downing the Lions, 20-13.
"It was designed for me to go outside, but I felt they had a lot of pursuit that way, so I cut inside," said Rice, who has scored 48 touchdowns in 49 NFL games. "We tried to run the ball to take some pressure off our passing. The most important thing was to establish the running game.
"Detroit has a good defense. We didn't take them lightly. Our defense played an excellent game. They really won it for us."
The 49ers (4-1) scored their only other touchdown on John Taylor's 77-yard punt return that gave them a 17-3 lead early in the second half before the Lions (1-4) rallied.
Montana, who threw 4 touchdown passes a week ago against Seattle, didn't throw a scoring pass for the first time this season and settled for 182 yards passing. San Francisco rushed for 176 yards, Roger Craig gaining 90 of them.
"Our (pass) protection was breaking down at the tackle positions, so we went to the run," Coach Bill Walsh said. "Their defense was very good. We went away from what we planned to do with the passing game."
Detroit pulled to within 7 points when Long threw an 11-yard touchdown pass to Pete Mandley with 4 1/2 minutes left in the game.
But the 49ers held the ball until the final gun by moving 60 yards, mostly on the running of Craig and fullback Tom Rathman.
Eric Hipple replaced Long at quarterback in the second quarter and got the Lions back into the game by passing for 136 yards before he suffered a broken ankle on a third-quarter sack.
After Rice's touchdown, Detroit's Eddie Murray it 7-3 with a 24-yard field goal, and Mike Cofer kicked a 29-yarder for San Francisco just before halftime.
After Taylor's return, Murray kicked a 34-yard field goal late in the third quarter but Cofer hit from 29 yards to rebuild the 49ers' lead to 20-6 before Long's scoring pass.
Long, who has started all of Detroit's games, completed 11 of 19 for 190 yards and was sacked 3 times before being replaced by Hipple, whose only sack came on his last play.