A gas station at the Washington, D.C. Costco is the center of a battle because the store also sells liquor. (Sarah L. Voisin/The Washington Post)

There is no cheaper gasoline to be had these days, at least in the District of Columbia.

And so the cars have lined up in a remote corner of Northeast Washington, a half-dozen deep on a recent Sunday afternoon, waiting to pull up to one of 16 pumps selling 87 octane at $2.99 a gallon.

Drivers might assume that they are buying their gas from Costco — the pumps, which opened in September, are less than 500 feet across a parking lot from the doors of the warehouse retailer’s only D.C. outlet. Buyers must be Costco members, and the “GASOLINE” sign on the canopy is rendered in the same type style as the Costco logo.

In fact, they are not. Nowhere at the station does the word “Costco” appear, and receipts issued at the pumps indicate that drivers are buying their gas from “CWC WDC.”

The branding discrepancy is an indication of the gas station’s tortuous history, a battle that has stretched nearly two years and has a retail giant going up against the city’s largest owner of gas stations.

The dispute pits claims of an unfair corporate loophole against allegations of anti-competitive behavior intended to protect high gas prices. It has involved some of the city’s top law and lobbying firms and has played out before community groups, a zoning board, liquor licensing authorities, the courts and now the D.C. Council. It has included, besides reams of paper and hours of hearings, insinuations of illicit payoffs and allegations of death threats.

“This is serious, serious business,” said Bob King, a veteran civic activist who lives in the neighboring Fort Lincoln neighborhood and supports the gas station. “If this was done back in the ’40s, blood would be everywhere. There would be a shootout at Bladensburg Road just like the shootout at the O.K. Corral.”

The fight’s roots go back three decades, to a 1983 D.C. law meant to discourage drunken driving by prohibiting the sale of alcoholic beverages at places selling gasoline. Because the Costco, which opened off New York Avenue last November, sells beer, wine and spirits, it is not permitted to sell gas — as all but three of the 22 Costco stores in the District, Maryland and Virginia do.

But the retailer, with the assistance of the Holland & Knight law firm and the support of city officials, devised a way around the law. In March 2012, nine months before the store opened, Costco moved to divide its Northeast lot in two and create a subsidiary company — CWC WDC LLC, wholly owned by Costco Warehouse Corp. — to operate the gas station. In the subsequent months, Costco was granted its liquor license while the gas station moved through the zoning process.

Then the politics of the D.C. gasoline business intruded: A group of gas station operators challenged the zoning approval and sought to retroactively protest the liquor license.

Most of the gas dealers, but not all, do business at stations owned and supplied by Eyob “Joe” Mamo, a Virginia businessman who owns the majority of the city’s filling stations, including two that are less than a half-mile from the Costco. The dealers are represented by lobbyist John R. Ray, a former D.C. Council member now with the Manatt law firm, who has long represented Mamo in various political and regulatory matters.

Proponents of the gas station say Mamo and his dealers drummed up opposition to protect their profit margins from a fearsome new competitor. The dealers argue that the subdivision of the lot was an illicit dodge of the long-standing ban on alcohol sales at gas stations. And if Costco can sell booze, they should be allowed to, also.

“The government decided they were going to do anything and everything to get Costco into town, including not complying with the law,” Ray said in a recent interview. “In no other jurisdiction do they have this scheme.”

Joined by some community activists, the dealers have fought the proposals at a series of hearings and meetings, including a contentious vote held more than a year ago by the local elected advisory neighborhood commission, which King serves on.

It was in the run-up to that meeting, which ended with the commission supporting the gas station, when King said he received death threats by phone to his home. At the meeting, a Holland & Knight lawyer reportedly helped count votes, leading to objections from station opponents. And afterward, a fellow commissioner accused King of “possible kickbacks,” an allegation King strongly denies.

With the support of the neighborhood commission and top economic development officials for Mayor Vincent C. Gray (D), the Board of Zoning Adjustment approved the gas station last November, and later that month, the Alcoholic Beverage Control Board refused to reconsider the liquor license. Construction proceeded.

Earlier this month, according to AAA Mid-Atlantic, the station sold the first sub-$3 gallon of gas in the District in five years.

AAA spokesman John B. Townsend II said the new station’s prices have consistently been 30 cents below the average for regular gas in the District, where prices are generally at least 5 percent higher than in Maryland and Virginia.

A gallon of Costco’s premium gas is cheaper than the average gallon of regular gas sold in the District, Townsend said: “That is amazing.”

But the fight goes on. The gas dealers and a group of community activists have gone to the D.C. Court of Appeals, seeking to force the liquor board to reconsider Costco’s license. Oral arguments in the case are expected early next year.

The dispute has also entered the political sphere. D.C. Council member Kenyan R. McDuffie (D), who represents Ward 5, where the Costco is located, quietly introduced legislation last month that would exempt the land that the warehouse and gas station occupy from the restriction on selling liquor at gas stations.

McDuffie said the bill, introduced at the behest of Costco, is “expressing the will of my constituents” who want cheaper gas.

“I don’t see where this claim is about the safety of D.C. residents,” he said. “It seems to be more about competition.”

Mamo has come under recent scrutiny for anti-competitive practices. A year-long antitrust investigation launched by the D.C. attorney general in 2011 did not result in any enforcement action, but he is being sued by the District over contracts with his dealers making him their exclusive gasoline supplier. Mamo has described those agreements as routine and continues to fight the claim.

In an e-mailed statement, Mamo said his and his dealers’ objections have “nothing to do with competition and everything to do with fairness.”

“If Costco is allowed to sell both gasoline and liquor, then my tenants should be able to do the same,” he said.

Ray is now pressing that position before the council. This month, he dispatched a letter to council members, decrying McDuffie’s bill as a “piece of self-interest legislation” meant to legalize a “deceptive corporate structure.”

“Big and small businesses, strong and weak businesses should expect the District government to ensure that its laws and regulations are applied fairly and equally to all,” he wrote.

But to many observers, comparing a 154,000-square-foot warehouse to a gas-station convenience store just doesn’t make sense. “I think you’re talking apples and oranges,” McDuffie said.

A recent visit to the D.C. Costco showed that the smallest quantity of alcohol available was the standard 750-milliliter bottles of wine or liquor, ranging from a $5.39 Moscato to a $2,199 Rémy Martin Louis XIII cognac. The smallest quantity for beer drinkers was a 12-pack of 22-ounce Sapporo cans, for $24.99.

To purchase those items after filling up, a driver would have to pull out of the pump bay, find a parking space perhaps hundreds of feet from the warehouse door, walk a football field’s length into the store to reach the liquor section, then walk just as far back to check out.

The AAA did not take a position on the gas station’s propriety during the zoning process, Townsend said, given the group’s dual role advocating for both lower gas prices and driver safety. But at this point, he said, the limited convenience of buying both gas and alcohol at a Costco would obviate any drunken-driving message.

“People are not going to have the same temptation,” he said. “You’re not going to be drinking a gallon of Jack Daniels in a Costco parking lot.”