General Motors Corp. yesterday won the bidding for Hughes Aircraft Co. with an offer of more than $5 billion, an acquisition that improves GM's strong position in high technology and makes the auto maker a major defense contractor.

The transaction, the largest of its kind outside the oil industry, will provide a windfall for Hughes Aircraft's present owner, the Howard Hughes Medical Institute, turning the Bethesda-based research center into the nation's largest nonprofit organization. The institute performs research in the fields of endocrinology, immunology and genetics.

"It's simply a boon to anybody who gives a damn about medical research," said Irving S. Shapiro, former chairman of E.I. du Pont de Nemours & Co. Inc. and chairman of the institute's board of trustees, in an interview. Shapiro said the institute would invest the proceeds of the sale of Hughes Aircraft in the stock and bond markets.

Donald S. Fredrickson, president of the institute, said he expected the sale of the company to more than double the research funds available to the institute to $200 million annually over the next year or so. "We will develop plans for use of the money, and we will keep you informed," he told a press conference.

Billionaire Howard Hughes set up the medical institute in 1953 to shelter income from Hughes Aircraft, which in spite of its name has never produced an airplane but rather is a maker of missiles, communications satellites and sophisticated electronics equipment, primarily for the Department of Defense.

The company is the institute's sole source of income, and the relationship has been hounded for years by legal disputes and challenges from tax authorities, who have charged that Hughes Aircraft did not contribute enough to the institute and that the arrangement was more of a tax shelter than a legitimate research-funding arrangement.

In 1983, the last year for which figures are available, Hughes Aircraft turned over $51 million in profits to the institute, on revenue of $4.9 billion. Last year, the contribution reportedly increased to about $80 million.

In part as an answer to this criticism, the medical institute trustees decided earlier this year to sell the company and invest the proceeds elsewhere. The institute's decision to offer the company through a sealed-bid auction drew interest from some of the biggest industrial corporations in the United States.

Under the terms of General Motors' bid, the institute will be paid $2.7 billion in cash and receive the remainder of the purchase price in the form of 50 million shares of a new class of GM stock -- a package estimated to be worth a bit more than $5 billion.

General Motors' bid was chosen by the medical institute's trustees over offers submitted by Ford Motor Co. and Boeing Co. as part of a five-month-long auction of Hughes Aircraft held in tight secrecy. Bidders were not allowed to publicize any details of their offers, and Hughes Medical Institute officials were vague even about the procedures of the bidding.

Shapiro said General Motors' offer was clearly the best of those screened for the institute by investment banker Morgan Stanley & Co. "They simply preempted the process with their bid," he said. "There just wasn't any ambiguity at all. It was so clear-cut that everybody saw it the same way."

There was speculation on Wall Street yesterday that Ford and Boeing might now seek other merger partners with heavy involvement in the defense industry, with one prevalent rumor linking Ford to Sperry Corp. Ford acknowledges its interest in buying an aerospace firm, but has declined to comment on specific companies.

Analysts said other industrial companies also might seek out acquisitions of defense contractors or aerospace firms, and noted that Chrysler Corp. already has expressed interest in taking over aircraft-maker Gulfstream Aerospace Corp.

Other possible aerospace-industry companies considered takeover targets on Wall Street include Grumman Corp., Northrop Corp. and Bethesda-based Martin Marietta Corp. The stocks of all three companies hit new highs in New York Stock Exchange trading yesterday.

The bidding for Hughes Aircraft already has spawned one related merger; Allied Corp. and Signal Cos. Inc., after considering a joint bid for Hughes, decided instead last month to join forces in a $4.9 billion combination.

The aerospace companies are seen as attractive partners for industrial giants because they provide a steady flow of income from defense work as well as access to leading-edge technology in such fields as electronics and materials.

General Motors Chairman Roger B. Smith said the acquisition of Hughes would give GM a strong base of knowledge in sophisticated electronics and allow the company to build better automobiles as well as to compete in new fields. "I'm a firm believer that the major gains in the automotive industry are going to come in electronics," he told a New York press conference. "The whole string in the corral that Hughes has is exactly what GM needs to move in the direction we want to in the future."

"We decided that we are going to build our company for the 21st century," Smith said. "We believe if we plan our future, we will have a future -- and that's why Hughes is so important to us."

Since becoming chairman of GM four years ago, Smith has been transforming the company, steering it into new fields to reduce its dependence on the automobile market and trying to apply technology to all aspects of the company's traditional activities.

Just last year, General Motors surprised the corporate world with a $2.55 billion acquisition of Electronic Data Systems Corp., a maker of sophisticated computer systems and software. That put GM into the forefront of the high technology field. Smith has made no secret of his desire to add a large defense contractor to the company, and has been promising stockholders a "lulu" for several months.

"Lulu has come home," Smith said yesterday. "It's a super historic day for us."

Assuming the deal is approved by GM shareholders, the auto maker will operate Hughes as an independent subsidiary, to be known as GM Hughes Electronics Corp. The division also will include GM's Delco Electronics, Delco Systems Operations and AC Spark Plug instrument and display systems operations.

Allen E. Puckett, chairman of Hughes Aircraft, based in El Segundo, Calif., said, "We see this as a great new opportunity . . . . We will continue our traditional activity in the aerospace industry, but we see new opportunities to move into a new direction in the application of new technologies in the automotive world." Puckett is to become chairman of the new GM division.

The addition of Hughes' revenues to GM's will put General Motors very close to overtaking Exxon Corp. as the nation's largest industrial company, as ranked by annual sales -- a position GM held until several years ago. Together, GM and Hughes had 1984 revenues of $88.8 billion; Exxon's were $90.8 billion.

GM did about $1 billion in defense work in 1984, making it the No. 23 supplier to the Pentagon. Hughes is the nation's seventh-largest defense contractor; it built $3.2 billion worth of missiles, radar systems and sophisticated electronics for the Pentagon in 1984. It also produces electronics equipment and communications satellites for commercial markets, giving it total 1984 revenue of $4.9 billion. The company received $6 billion in new orders last year and had a $12 billion year-end backlog.

But despite the company's flush financial condition, officials of the Internal Revenue Service and the state of Delaware -- where both the institute and the company are incorporated -- have long alleged that it was not providing much of an income to the medical institute that was sheltering it from taxes.

The state and a relative of Hughes also had charged that a group of Howard Hughes' associates had taken advantage of confusion over the late billionaire's missing will to improperly take control of the institute -- and thus the company. After a lengthy trial, a Delaware judge last year declared invalid a change in the institute's bylaws that had allegedly been approved by Howard Hughes and ordered the appointment of a new board of trustees, including Shapiro, to oversee the institute's affairs.

The new board quickly determined it could produce more money for the institute by selling Hughes Aircraft and putting the proceeds into other investments, so it hired Morgan Stanley to advise it on how to sell the company.

Yesterday, Shapiro said he hoped the sale of Hughes Aircraft would enable the institute to settle the longstanding Internal Revenue case against it that complains that the institute was not receiving enough income from its assets for spending on research.