LOS ANGELES — Voters of Hermosa Beach, a small community on the Pacific Ocean south of here, ended a highly contentious campaign Tuesday with an overwhelming vote to deny permission for the construction of up to 34 oil wells on a 1.3 acre municipal parking lot in the center of town. According to unofficial returns, the measure was defeated 3,799 to 1,016.

The initiative would have created an exception to what is currently a ban on oil drilling there, in order to permit E&B Natural Resources Management to proceed with a previously approved contract to do the drilling.

As a result of the vote, Hermosa Beach now owes E&B $17.5 million to terminate the contract, under the terms of an agreement ending litigation with the firm. The drilling had been opposed by the entire City Council, whose members said that the drilling posed unacceptable environmental risks to the city and was not in keeping with the aesthetics of this small beach community.

The city has a surplus of close to $7 million that it has put aside to help pay the penalty. The rest would be paid in roughly $800,000 annual installments.