By the time the dials on the Exxon station's gas pump had spun up a total of nearly 40 gallons, Joseph L. B. Murray knew the pump had gone berserk. His Thunderbird's gas tank holds only 22 1/2 gallons.

What had happened at the Connecticut Avenue gasoline station could only be blamed on a bizarre breakdown of technology: the excess gas had simply flowed to Murray's tank through one hose and out through the other.

Why the twin hoses? They are part of the District of Columbia's long and often-controversial battle against air pollution.

The District is the only region of the United States - apart from two sections of California - that has ordered gas stations to equip their pumps with double hoses and specially designed nozzles as an antipollution measure. The first hose is meant to put gas into an auto's tanks; the second hose is intended to draw off hydrocarbon vapors to keep them from polluting the air.

But as Murray and other auto owners here have already discovered, the antipollution gadgetry is apt to go haywire. Not only do the newly equipped pumps sometimes pour out more gas than a car's tank can hold, but they also may leak, spill gas on the ground or splash it on station attendants and their customers. The special nozzles have stuck in gas tanks repeatedly and have had to be pried out, broken off or sawed loose. Occasionally they do not fit at all.

The leaks, spills, splashes and other mishaps, at attendant-operated as well as self-service pumps, have raised considerable doubt about whether the new contraptions have led to any reduction in air pollution since they were ordered into use last year.

The government-mandated devices also have angered many of the city's more than 300 gas station operators, most of whom have had to so spend several thousand dollars for the nozzles, hoses and additional underground pipes. The controversy has stirred concern among some of the Washington area's air pollution specialists and drawn attention from an increasing number of politicians, including Mayor Walter E. Washington and Sen. Mark O. Hatfield (R-Ore.).

Hatfield happened to pull into a Georgetown service station a few months ago when one of the special nozzles got stuck in another customer's tank. He watched as station attendants struggled to pry it loose.

"Here's technology that hasn't worked out and they're forcing it on the consumer," an aide later quoted Hatfield as saying, after telephoning Hatfield's complaint to city and federal environmental officials.

Mayor Washington, responding to the gas station operators' criticism of the double hoses and special nozzles, set up a task force last month to see what steps could be taken. The task force already is considering calling for a temporary moratorium on the troublesome nozzles until improved equipment is on the market. The mayor, who is campaigning for reelection, won a quick political endorsement from the gas dealers, who are represented by the Greater Washington Maryland Service Station Association Inc.

The District and its new nozzles seem, nevertheless, to have gotten themselves ensnarled in a paradoxical dilemma that stems partly from federal clean-air laws and partly from U.S. Enivronmental Protection Agency mandates.

Because the District already has ordered gas stations to install the double-hosed rigs, it is virtually prohibited under federal laws from undoing what it has done, according to an EPA official. Any such move, the EPA official explained, would constitute a relaxation of the District's antipollution efforts. Under the Clean Air Act of 1970, the official said, such a relaxation would be barred unless the District simultaneously institutes some other equally far-reaching antipollution measure - an obstacle regarded as almost insurmountable by some officials.

Maryland and Virginia have refused to require the new nozzles.

The new hoses and nozzles were intended to help combat one of the Washington area's toughest air pollution problems. Hydrocarbons are a key ingredient in the chemical reaction that produces photochemical smog, the area's most severe form of pollution. Hundreds of tons of hydrocarbon vapors are released into the atmosphere every year at gas stations here. The new gadgetry is aimed at reducing these vapor emissions by as much as 90 percent, thereby cutting down on smog.

The hydrocarbon vapors also contain small amounts of benzene, a substance that EPA officials describe as linked with leukemia, a form of cancer. Benzene vapors emitted at gas stations may pope a health hazard for station attendants, motorists who stop to get their tanks filled and residents of surrounding neighborhoods, EPA officials say.

The District government ordered gas stations to install the double-hosed rigs to order to carry out part of a controversial 1973 EPA plan aimed at reducing Washington's pollution. The tips of the nozzles are encased in a rubber bellows designed to form a seal around the openings of a gas tank and thus prevent vapor from escaping while it is being filled.

The city-imposed deadline for installing the equipment was May 31, 1977, though some stations won extensions up to last fall. Almost all stations appear to have complied.

California already had embarked on a similar campaign. In San Diego and the San Francisco Bay area, measures requiring gas dealers to install double hoses quickly resulted in technological breakdowns, controversy and court challenges. The California legislature eventually stepped in and called a moratorium on use of the special nozzle until the equipment - without bugs - wins official state approval.

The District's nozzle problems have been blamed on a variety of miscalculations and shortcomings. Government officials have been accused of rushing ahead before gas-pump technology had a chance to catch up with the antipollution demands. Gas dealers have been accused of installing less expensive, faulty equipment and then failing to maintain it adequately.

"Somebody just sold the District council a bill of goods on these things, because they just don't work," complained Denny Garrett, who owns the Connecticut Avenue Exxon station where Murray ran up his nearly 40-gallon tab for filling his 22 1/2-gallon Thunderbird tank.

Murray, an insurance broker, remembers his encounter with the berserk gas plump with a mixture of bewilderment and annoyance. "The damn thing went up to 38, 39, 40 [gallons] and I said, 'Where are you Putting all that?'" Murray recalled a few weeks ago. "I said, 'When is it going to stop?'"

Other dealers and customers tell similarly outlandish tales.

John McQueeney, who runs a self-service Exxon station on Bladensburg Road NE., remembers a woman who stopped to get gas on her way to a wedding, wearing a white organdy dress. "The damned stuff shot all over her," McQueeney said. Such gasoline splashes are said to be caused by excess pressure that builds up in a tank when the double-hosed, tightly sealed nozzles malfunction.

At an Amoco station on Connecticut Avenue NW, an attendant had to use a wire coat hanger to open the valve in a Toyota's tank because the city-mandated nozzle would not fit. Then the coat hanger got stuck in the tank. It took almost 10 minutes for the attendant to yank in out.