Hometown favorite Bill Rodgers won the Boston Marathon for the second time yesterday, holding off fast-closing Jeff Wells, a Dallas seminarian, by two seconds. It was the closest finish in the 82-year history of America's oldest and most celebrated distance race.

Rodgers, 30, a Newington, Conn., native who emerged last year as the world's premier marathoner with victories in New York City and Fukuoka, Japan, ran the 26 miles, 385 yards from suburban Hopkinton to the Prudential Center in downtown Boston in 2 hours 10 minutes, 13 seconds.

That was just 18 seconds off the American record of 2:09:55 set by Rodgers in 1975 when, as an unheralded Boston College graduate student, he captured the champion's laurel wreath in Boston's Patriots Day Classic with his first world class performance.

Rodgers' effort yesterday, wildly cheered by the huge crowds that lined the famous course and jammed every vantage point at the finish in Copley Square, was the third fastest marathon ever run on American soil. In addition to his 1975 record, achieved with a rare tailwind, Rodgers holds the second best American time: 2:10:10 in the New York City Marathon in 1976.

But the former teacher of retarded and emotionally disturbed children, who now lives in Melrose, Mass., and operates a running supplies store on the marathon route in Newton, struggled the last six miles. He crossed the finish line a scant 40 feet ahead of Wells, 24, a Rice University graduate who now attends the Dallas Theological Seminary.

The previous closest finish was in 1971, when Alvaro Mejia of Colombia outkicked Bostonian Pat McMahon by five seconds.

"There was little I could do except hold on and hope for the best. The last six miles I was just maintaining. I was falling apart. I never had to gut it out as hard as I did today," said Rodgers, who became aware of Wells' charge two miles from the finish when a motorcycle policeman told him, "Someone is closing fast on you."

Esa Tikkanen of Finland finished third in 2:11:15, two seconds ahead of 1976 champion Jack Fultz, a Georgetown University alumnus now living in Franklin, Pa.