Ray Wersching's 22-yard field goal with four seconds to play gave the San Francisco 49ers a 30-27 victory over the Detroit Lions today.

The rematch of last year's NFC playoff game between the Western and Central division champions drew a crowd of only 56,782 in the 80,638-seat Silverdome. There were 3,352 no-shows. But the last two times the Lions opened at home on a Labor Day weekend also were their smallest crowds.

Detroit receiver Leonard Thompson caught a pass from Gary Danielson in stride at the 25 and scored to complete a 49-yard play that made it 27-27 with 5:01 left.

The 49ers had broken a 20-20 tie at 6:35 of the fourth quarter on a nine-yard run by Wendell Tyler the first play following a 55-yard punt return by Dana McLemore, who broke a tackle by Thompson.

"It takes a talented player to get a big return like that," 49ers Coach Bill Walsh said. "The return gets 10 yards and the rest is up to the player."

"It was too bad we had the punt return run down our throats," Lions Coach Monte Clark said. "We thought we had a clear edge in that area and had worked on it a lot in practice."

Danielson put the Lions ahead, 20-14, with a two-yard pass to James Jones at 8:24 of the third quarter. Wersching kicked a 42-yard field goal at 14:10 of that quarter to pull the 49ers to 20-17, then kicked a 53-yarder, longest in his career, to make it 20-20 at 4:31 of the fourth quarter.

Danielson, intercepted five times during the Lions' 24-23 defeat in the NFC playoff game on New Year's Eve, was 17 of 24 passing today for 177 yards and the two touchdowns, with no interceptions.

Montana, the top-rated quarterback in the NFL, was 16 for 25 for 188 yards and one touchdown, and had no interceptions.

The Lions had a third and 10 on the 49ers' 49 when Danielson found Thompson running open at the 25. Thompson had missed all of training camp because of a contract dispute. After Carl Monroe returned the kickoff 25 yards to the 49ers' 25, Montana had 4:51 to get his team down the field.

The 49ers drove 71 yards in 11 plays to set up Wersching's winning field goal. Montana hit veteran tight end Russ Francis for 22 yards and Tyler got off a 14-yard run.