GenVec Inc., a Gaithersburg biotechnology company, agreed yesterday to buy specialty drugmaker Diacrin Inc. for $40.4 million in stock, in a move to bolster its cash reserves.

Neither company is profitable, but Diacrin's money will help GenVec until it can produce a marketable medical product. Diacrin, based in Charlestown, Mass., is developing a cell-transplant technology designed to repair damaged heart tissue. GenVec is working on three treatments: TNFerade for cancer, BioBypass for coronary artery disease and PEDF for blindness.

Executives said they would exchange each share of Diacrin for 1.5292 shares of GenVec, valuing Diacrin at about $2.23 a share, based on GenVec's Monday closing price of $1.46. The terms of the agreement represent a premium of 94 percent, given Diacrin's closing price of $1.15.

If regulators approve the merger, expected to close in the third quarter, Diacrin shareholders will own about 54.5 percent of the combined company, while GenVec shareholders will own 45.5 percent. The companies said they have been in discussions for about four months.

GenVec, which reported $20.3 million in cash on hand as of Dec. 31, said the combined company would have $50 million at the end of this year, strengthening its bargaining position as it tries to find partners to help develop its drugs. Under the deal, GenVec would retain its name and would also gain extensive manufacturing facilities, eliminating the need for outside contractors.

"GenVec was product-rich and cash-poor," said Craig D. West, an analyst at A.G. Edwards & Sons Inc., who owns stock in the company. "Now they are product-rich and cash-rich."

The deal was billed as a merger of equals, but it became clear yesterday that, in the near term, it is about TNFerade, GenVec's cancer-fighting treatment. The company's chief executive, Paul H. Fischer, said the combined company will be able to fund its operations through 2006, when he hopes the product will be ready for federal approval.

TNFerade, a type of gene therapy, is injected directly into the site of a tumor and becomes activated by radiation. GenVec is conducting tests for it in patients with cancer of the pancreas and esophagus.

"We did not want to be dependent on a partnership or a financing at any particular time," Fischer said. "This will alleviate the concern of our shareholders that GenVec will not be able to execute on our business plan."

Fischer said he plans to keep GenVec's annual cash spending rate under $20 million. Today, it stands at $18 million per year, while the rate at Diacrin is between $4 million and $5 million.

As a result, Fischer said, GenVec's remaining two drugs -- and Diacrin's cell-transplant technology -- would require partnerships to move forward with expensive patient tests.

GenVec has 95 workers, and Diacrin has a staff of 25. About 30 employees would be cut, though it is not yet clear where, GenVec said. Fischer is expected to remain the company's chief executive, and Diacrin's chief executive, Thomas H. Fraser, is expected to become chairman.

The deal continues a wave of recent consolidations in the battered biotechnology sector, which has found that mergers are often a safer alternative to dilutive equity sales and sometimes stingy license agreements.

In the past three months, Johnson & Johnson agreed to buy biotech concern Scios Inc. for $2.4 billion; Cambridge Antibody Technology PLC announced plans to buy Oxford GlycoSciences PLC for about $178 million; and NPS Pharmaceuticals Inc. agreed to pay $571 million in stock for Enzon Pharmaceuticals Inc.

One of GenVec's labs at the company's Gaithersburg headquarters. GenVec sees the Diacrin deal as strengthening its position as it looks for partners to help develop its drugs.