SAN FRANCISCO, NOV. 25 -- The San Francisco 49ers say they were concentrating on the Los Angeles Rams, not the New York Giants.

A week before a much-ballyhooed game against the Giants, the 49ers committed six turnovers and had their 18-game winning streak -- one short of a league record -- come to an end today with a 28-17 loss to the Rams.

"The Rams have a bad record, but they're not a bad football team, for whatever reason," 49ers linebacker Matt Millen said. " . . . I don't think we were looking ahead."

Cleveland Gary scored three touchdowns and fullback Buford McGee threw for one touchdown and ran for one as the Rams (4-7) became the first team to defeat the 49ers since the Green Bay Packers did it Nov. 19, 1989.

"Coming into this game, I thought this game was more significant than the Giants game," 49ers safety Ronnie Lott said, "because when you play a team that is very familiar with you -- I think we played these guys four times last year -- they definitely know us. They definitely know where to attack and what to do against us."

For the Rams, the victory made up for a season's worth of disappointment.

"This proves we can play with the big boys," said linebacker Kevin Greene, who recovered two fumbles.

The 49ers' Joe Montana turned the ball over four times in a wind-driven rainstorm, fumbling once and throwing three interceptions for the first time since Sept. 18, 1988. Montana completed 22 of 37 passes for 235 yards and two touchdowns.

Tom Rathman and Jerry Rice also lost fumbles for San Francisco, which lost for the third straight year to the Rams at Candlestick Park.

"I don't know why the Rams seem to play us so tough at Candlestick," running back Roger Craig said. "But when you make as many mistakes as we did, you're going to lose the ballgame."

The Rams opened a 21-7 halftime lead thanks to four San Francisco turnovers. But the 49ers (10-1) scored 10 third-quarter points, pulling to 21-17 on a 42-yard field goal by Mike Cofer with 1:20 left in the period.

A 23-yard touchdown pass from Montana to Harry Sydney with 6:05 left in the third quarter started the rally. Sydney took a screen pass left, then zig-zagged off three tacklers before reaching the end zone, capping a four-play, 62-yard drive.

However, the 49ers' next possession ended when Montana was intercepted by Vince Newsome at the Rams 10-yard line. The Rams then marched 90 yards in 17 plays.

The drive, which lasted 10 minutes 37 seconds, was climaxed by a one-yard touchdown run by Gary, who lost control of the football momentarily before slicing into the end zone.

The 49ers were the fourth NFL team to win 18 consecutive games. They share the record with the 1933-34 Chicago Bears, the 1941-42 Bears and the 1972-73 Miami Dolphins.

The Rams started things off by parlaying Greene's second fumble recovery of the game and some trickery into their first touchdown.

McGee took a handoff, ran off-tackle right and shoveled a pass to Gary, who caught the ball one-handed and ran 22 yards untouched down the right sideline for a touchdown that gave Los Angeles a 7-0 lead with 6:23 left in the first quarter.

The Rams' second touchdown came three plays after Mike Wilcher recovered a fumble by Rice at the San Francisco 19-yard line, as Gary scored on a 10-yard run.