When William R. Barrett came to the Washington area to scout for a location for the expanding TRW Inc., he considered everything from high schools to airports and taxes to labor costs. In the end, however, the decision depended heavily on traffic jams.

"I'll be frank with you," said Barrett, administration director for TRW Defense Systems Group, "the Cabin John Bridge became a focus of attention" when a TRW employe waited in traffic for hours after a piece of the bridge fell off.

Montgomery and Fairfax counties each spent months luring the high-technology multinational company, promising sites convenient to the Pentagon, busloads of well-educated workers and a bounty of federal government contracts. But when it was all over, it was largely the ailing Cabin John Bridge that landed Fairfax County, and not Montgomery, the $25 million plum and the 1,000 jobs TRW has promised to bring in the next five years.

Fairfax's victory was the latest round of dogged competition between Fairfax and Montgomery counties, two strikingly similar suburban jurisdictions in hot pursuit of the same corporate behemoths.

"Montgomery is the big rival because we're the same distance out from Washington," said Fairfax County Supervisor Audrey Moore. "We've got the same kind of demographics. We've each got quality schools, services and a good life style."

Both offer new corporate locations, bountiful public services, high incomes and what economic development officials call "critical mass," or enough high-tech businesses to act as bait for more.

In fact, the counties are so similar that a corporation's decision on where to locate can sometimes swing on something as minor as a jogging path.

The way Fairfax officials tell it, security-conscious TRW officials nearly canceled their big facility over just that -- a proposed public jogging path that ran too close to their planned Fairfax site. County officials quickly agreed to move the path. "It was a close call," said Fairfax County Executive J. Hamilton Lambert. "You could blow a whole deal up on a path."

The competition between the area's so-called supercounties is a quiet one, of course, conducted with more Wall Street decorum than Dallas dash. And never far from the fray is the name of Uncle Sam.

A recent national advertisement for Reston in Fairfax County, for example, noted the billion-dollar contracts handed out by the federal government each year and matter-of-factly reminded corporate executives that the high-tech firms already in Reston are "only 20 minutes from downtown, where the contracts for such goods are awarded."

Washington offers power, influence and a shot at the billions spent each year in federal contracts, and both Fairfax and Montgomery play the location to the hilt. Their advantage over non-Washington communities is considerable.

"You're not so much competing with the Route 128s Boston's high-tech corridor and the Silicon Valleys," said David Birch, director of the Massachusetts Institute of Technology's program on Neighborhood and Regional Change. "You have your own gig called: The U.S. Government and Ronald Reagan."

Thanks to the presence of the federal government, neither Fairfax nor Montgomery has to offer incentives such as the use of Lear jets or country club memberships that other parts of the country sometimes use as corporate lures.

Government money going to Washington area companies has more than doubled since 1979, increasing an average of 17 percent a year for the last three years, according to a Greater Washington Research Center report. The growth is largely due to an increase in the number of jobs previously done by federal workers being contracted into private hands.

Last year, about $6.7 billion went to more than 8,000 area firms, up from a little more than $3.3 billion in 1979, with the largest shares going to suburban businesses. As a new Fairfax ad advises: "There is probably nothing you can make that the U.S. government can't or won't buy."

Fairfax and Montgomery may be similar in the eyes of corporate search committees, but a closer inspection shows that they are not identical.

Suburban Maryland claims the largest share of government contracts -- $2.9 billion, or 42.9 percent of the metro area dollars, as opposed to Northern Virginia, which claims $2.5 billon, or 37 percent. But Fairfax claims more high-tech firms -- 525, compared with Montgomery's roughly 400.

According to a 1983 study by the Greater Washington Reserch Center, Montgomery gets the most Pentagon money of any local jurisdiction, $1.2 billion. Fairfax was second with $839 million; the District third with $544 million, and Prince George's fourth with $494 million.

Historically, Virginia officials have claimed that firms selling defense-related items have stuck to Virginia's Pentagon side of the river, referred to in a recent Forbes magazine story as the "warrior" side of the Potomac. Virginia also is perceived to be more conservative and southern.

By contrast, the emerging biomedical market supposedly has clung to Maryland, nearer to the National Institutes of Health in Bethesda, the largest of the county's federal medical agencies and the world's biggest coordinator and supporter of medical-related research. Forbes, to the delight of some Virginians, referred to the more liberal Maryland as the "wimp" side.

Both Montgomery and Fairfax seem eager to shed those images. Montgomery, for example, points proudly to the Vitro Corp., a Silver Spring-based supplier of weapons systems for the Navy, and the employer of 6,200.

Fairfax showcases Hazleton Laboratories near Tysons Corner, which employs 400 and has been in the county since 1946. Said County Executive Lambert: "I want to dispel this whole whoop-de-doo about us being only defense and telecommunications out here."

Both counties point to the metropolitan area's large pool of educated workers -- nearly 18,000 PhDs in the Washington area, or almost twice as many as Boston and Los Angeles, and 2 1/2 times as many as San Francisco, according to various advertisements.

Both counties also boast about median household incomes -- $47,600 in Fairfax and $35,682 in Montgomery -- and about their proximity to museums, the ocean and even Lord & Taylor stores.

The counties also advertise a favorable business climate, although local taxes are not necessarily an important factor in deciding where a high-tech company moves, according to MIT's Birch. High-tech needs smart people, he said, and smart people want quality municipal services that don't always come cheap.

Fairfax and Montgomery also acknowledge the same drawbacks, including overcrowded roads and the lack of any prestigious universities to link entrepreneurs, academics and prospective employes.

Virginia is now pressing its new $56.7 million Dulles Toll Road, the emergence of George Mason University, and soon will boast of the state-supported $30 million Center for Innovative Technology.

Maryland features its Metro system and speaks of Johns Hopkins in Baltimore and other area universities, as well as plans for its 288-acre Shady Grove Life Sciences Center, billed as the nation's first research and technology park for life sciences and the health care industry.

Still, because Montgomery and Fairfax are so similar, the decisions of where to go often seem to be based on a subtle blend of factors, including which county offers the quickest access to prospective customers, which has fewer traffic problems, which offers the better schools.

The Space Communications Co. selected Montgomery over Fairfax for several reasons, including its proximity to the firm's chief customer, the Goddard Space Flight Center, said spokesman John Duemmel.

Sperry, however, chose Fairfax for its new facility. "We thought the transportation problem would be more easily solved along the Dulles corridor than in Maryland," said James Popino, Sperry's director of administration and facilities.

Mike Markles Jr., president of Versar Inc., a research and technical manufacturing firm, said schools were an important factor a few years back in deciding whether to keep his company in Fairfax or expand elsewhere. Two of his children were in local school programs for the gifted, and he wanted them to stay.

Of the two counties, Fairfax has been marketing itself longer and more frequently nationally, with a corporate advertising budget that has swelled from $14,000 in 1976 to $500,000 today. That's more than is spent by some states, including Delaware, Wyoming and Rhode Island.

Fairfax also receives a big boost from the $930,000 the State of Virginia is spending to promote high technology and to reverse any images that Virginia is for Thomas Jefferson buffs, or for lovers only.

Montgomery's efforts are smaller, with less than one-third the advertising budget, forcing it to rely on trade journals, instead of The Wall Street Journal, which Virginia and Fairfax use extensively. The Maryland counties don't profit as much from Maryland's ads because people tend to associate the state with Baltimore, officials say.

Yet, Montgomery offers some services that Fairfax doesn't, including helicopter rides over prospective sites and a direct-mail campaign that targets an estimated 1,500 to 2,000 firms a year, focusing on those in electronics, space, computer software and biomedicine.

Both counties have "fast-tracking" systems to help developers negotiate the maze of permits and regulations, but Fairfax has one advantage, said Duc Duong, assistant director to Montgomery's Office of Economic Development. "In Fairfax, people can just develop anything they like. Over here, it would be more balanced control, which we believe is good for the community."

"Our ordinances are just filled with loopholes and waivers and they permit a much more inferior kind of development," said Supervisor Moore, who is known for her outspoken positions. "It's the reason that some Fairfax officials are so sensitive about Montgomery competition. They have higher standards than we do, and they're doing a better job than we are. But, the last time I said something like that, one of the board members said: 'Why don't you leave and go to Montgomery?' "