SOUTH PORTLAND — The controversial proposal to ban so-called tar sands oil from South Portland was defeated Tuesday in a close citywide vote.

The final tally was 51 percent to 49 percent against the Waterfront Protection Ordinance – with 4,453 votes against the ordinance and 4,261 in favor. Forty-five percent of the city’s registered voters cast ballots.

The 192-vote margin meant victory for the coalition of oil companies and waterfront businesses that opposed the law.

Jamie Py, president of the Maine Energy Marketers Association, was ecstatic after learning the election results. Now, he said, it’s time for South Portland residents and businesses to have a “real conversation” about the future of the city’s working waterfront.

That kind of discussion was impossible in recent weeks because the campaign became so divisive. “We were on two different planets,” he said.

Mayor Tom Blake said he is poised to initiate a process Wednesday to write a new law to prevent tar sands crude from flowing through the city’s six oil terminals.

The effort would begin with a 180-day moratorium on any project to reverse the flow of the 236-mile oil pipeline that connects South Portland and Montreal, which has been owned since the 1940s by Portland Pipe Line Corp.

Blake vowed to propose the moratorium to city councilors at a workshop Wednesday.

The temporary ban would prevent any effort to bring tar sands oil from Canada into the city, to give the council time to approve a new law that might accomplish what the defeated ordinance could not.

“It’s up to the councilors to come up with language that is satisfactory to keep tar sands out,” Blake said.

Py said that opponents won’t go away, and that waterfront businesses must address the concerns of the more than 4,000 people who voted for the Waterfront Protection Ordinance. But the forum for that conversation should be the City Council or the Planning Board, he said, rather than a citywide referendum.

“It needs to be about facts, not fear,” Py said.

At the Maine Military Museum, where about 30 opponents of the ordinance gathered to watch election coverage, cheers erupted as early returns showed the group – the Working Waterfront Coalition – far in the lead.

Several dozen volunteers spent Tuesday telephoning supporters, carrying signs at intersections and knocking on doors. The Working Waterfront Coalition is made up of energy companies, business groups and organized labor, including the union that represents South Portland’s firefighters.

The coalition includes people who typically don’t find themselves on the same side of issues, “but we’re all on the same side on this one,” said Jim Merrill, the campaign’s spokesman.

As the loss set in at the headquarters of Protect South Portland, the group that wrote the proposed law, a sudden hush fell over the crowd, followed by murmurs, questions and tears.

“We have such a motivated group of citizens here and I feel like we’re just going to keep working to prevent tar sands,” said Carolyn Graney, who spoke after announcing the results.

Since June, the campaigns to sway residents on the issue have divided the city. Political signs blanketed roadway medians, front lawns and storefront windows. Canvassers knocked on thousands of doors and called countless voters. Outside money poured in on both sides, although petroleum interests deeply outspent their opponents.

South Portland has long been an oil-handling port, not only for crude piped to Canada.

Waterfront terminals have for decades received shipments of home heating oil, gasoline, jet fuel and other petroleum products, which are stored in massive tank farms that dot the city’s shores and suburban neighborhoods before trucks distribute them around northern New England.

Portland Pipe Line Corp., which has an 18-inch pipe and a 24-inch pipe, has experienced a decline in demand for the oil it pumps into Canada. In 2009, the company received state and local permits to reverse the flow of one of its pipes to bring Canadian crude oil from Alberta into South Portland for loading onto tankers that would ferry it to refineries overseas.

Tar sands oil has become a target of environmentalists, who say its development will accelerate global climate change and pose other environmental risks. The petroleum industry has said it poses no greater risk than other oil.

In its raw form, the crude is a mixture of sticky petroleum, water and sand that at room temperature has the consistency of cold molasses. It is mixed with a cocktail of potent chemicals that dilute its consistency, so that it can be handled efficiently and pumped through piping. The product is referred to as diluted bitumen.

The project envisioned in 2009 would have added loading arms and two 70-foot-tall smokestack structures to Portland Pipe Line Corp.’s pier, next to Bug Light Park. The stacks, called vapor combustion units, would have burned off gases associated with the loading of diluted bitumen onto tankers.

Portland Pipe Line Corp. eventually decided not to pursue the project, but a state environmental permit allowing the company to build the stacks remained on the books, and was renewed in August 2012. That led many people to believe that the company still wanted to bring the tar sands oil through South Portland. The company made a point of surrendering the permit this fall.

On its face, the amendment to the city zoning would have redefined the allowable uses in the city’s shipyard zone and other parts of the waterfront, strictly defining the unloading of petroleum as an allowed use and limiting any expansion or alteration of petroleum facilities that would change their function or capacity.

Portland Pipe Line Corp. and other waterfront businesses that handle and distribute petroleum products rallied against the proposal.

Attorneys for the companies objected to the ordinance’s wording, particularly phrases that would restrict expansion or enlargement of the facilities, which they argued would trigger the demise of their clients’ massive businesses.

Without the ability to maintain, update and alter equipment, they said, the industry would whither, taking with it millions of dollars in municipal tax revenue and countless jobs.

Matt Byrne can be contacted at 791-6303 or at:mbyrne@pressherald.com