BEVERLY HILLS, Calif. — The Subway to the Sea, a train that would tunnel more than 15 miles from downtown Los Angeles to the Pacific Ocean, has encountered no shortage of obstacles over the years: from how to pay for it to skepticism about a huge mass transit project in a region that once ripped out trolley car tracks to make way for automobiles.

Now, a new impediment has stepped onto the tracks: Beverly Hills High School.

Beverly Hills has gone to court to block the proposed subway line from burrowing under a high school celebrated for its roster of famous graduates and its ZIP code. Beverly Hills contends that the tunnel poses a safety threat to students — the high school is built on a still-active oil field and is near an earthquake fault — and would interfere with the school district’s plan to spend close to $120 million on renovating the building and the campus.

The dispute has stirred tensions between Beverly Hills school officials and Los Angeles transit advocates, bringing to the surface — unfairly, Beverly Hills residents said — old charges that the community, synonymous with wealth and privilege, does not want to open its borders to mass transit and the not-so-prosperous people who ride it. The city, residents point out, has not objected to two other stops near Beverly Hills, only the Century City stop, which requires a detour under the high school.

The Subway to the Sea is the centerpiece of a campaign by Antonio R. Villaraigosa, the mayor of Los Angeles and a member of the transit authority, to expand mass transportation offerings in a region increasingly gripped by traffic congestion.