Fairchild Industries Inc. yesterday sole more than 1.2 million shares of stock in Bunker Ramo Corp. to Allied Corp., ending a two-year takeover fight, and earning a profit of more than $32 million inthe process.

The deal with Allied, formerly Allied Chemical Corp., comes just two weeks after Fairchild Chairman Edward Uhl said his firm "still intends to try to put the companies [Bunker Ramo and Fairchild] together."

John Dealy, president of Fairchild, the Germantown-based aerospace, technology, and communications conglomerate, said, in effect, that this company could not turn down the high price and that the cash transaction will enable Fairchild to build existing subsidiaries and keep an eye out for other acquisitions.

"Fundamentally, the Allied people have come in and made a very firm offer to acquire our shares on terms we consider acceptable," Dealy said in an interview. Dealy said other potential purchasers have approached Fairchild about its Bunker Ramo holdings, but the Allied deal was particularly appealing because it involves cash. "We were not interested in taking someone else's securities," he said.

Dealy said that Fairchild has an "active acquisitions committee" that is studying other possible merger transactions. The company is interested in purchasing technology firms that would "enhance either our commerical-industrial sector or our aerospace business," Dealy said.

Allied purchased the Bunker Ramo shares held by Fairchild for $55 a share, bringing the total price of the deal to $70.21 million. Most of the shares were purchased by Fairchild in 1979 at an average cost of $24 a share. As of March 29, 1981, the value of Fairchild's investment in Bunker Ramo was listed at $38 million, the company said.

The boards of directors of both Bunker Ramo, a suburban Chicago computer technology company, and Allied announced the deal that involves both the Allied purchase of Fairchild's 1,276.667 Bunker Ramo shares. It also plans for a separate tender offer for as many as 1.175 million shares of Bunker's stock at $55 a share. The Allied purchases would give the New Jersey company almost 50 percent of Bunker Ramo's stock. The per-share price of the stock closed Friday at $54.25 after a $2.75 a-share jump in value.

Fairchild's efforts to take over Bunker Ramo had been stymied by two rejections and occasionally bitter exchanges between the leadership of the two companies. Fairchild's interest in Bunker Ramo began with the purchase of 20.6 percent of Bunker's stock from Martin Marietta Corp. Ultimately, Fairchild was able to win two seats on Bunker's board, but the company also signed an agreement prohibiting further purchases of Bunker's stock until next year.

The Bunker Ramo acquisition was particularly important in Fairchild's continuing efforts to move away from a reliance on defense and related government contracts. The development of the company's statellite communications business and its $280 million purchase last year of VSI Corp., a California plastics and tooling equipment company, are part of that move.

Bunker Ramo would have brought Fairchild into the computer information system business, a field that company officials felt would have been complementary to its statellite and other high-technology interests.