Financier Carl C. Icahn and Trans World Airlines Inc. have scrapped an agreement for him to buy the carrier and entered into a pact under which he will become chairman and control its board, the financially troubled company announced late today.

The new arrangement, detailed in a lengthy statement from TWA's New York corporate offices, came against a background of serious losses for TWA, the nation's fourth-largest airline, which Icahn had agreed to buy more than three months ago following a protracted takeover battle with Texas Air Corp.

The statement said TWA may have lost up to $140 million for 1985, double an earlier estimate.

"Termination of the merger agreement occurred following recent adverse operating results for TWA and difficulties encountered in raising financing for the merger on its original terms," the statement said.

Icahn, who owns 52 percent of TWA's stock, had offered to buy the rest for $24 a share, consisting of $19.50 in cash and $4.50 in securities under a Sept. 26 agreement, but had trouble obtaining the estimated $800 million he needed to complete the purchase because of investor concern about TWA's profitability.

Under the new agreement, Icahn will exchange only $24 a share in preferred stock and no cash for a portion of the shares he does not already own, the TWA statement said.

Icahn also became chairman of the TWA board under the pact, and two of its non-Icahn-affiliated members resigned, giving him control.

The announcement came a day after officials of TWA's pilots and machinists unions said they had reached definitive agreements on new contracts with Icahn that offer substantial concessions deemed necessary for the carrier to improve financially.

Those agreements stipulate that Icahn must control the board before the concessions can be enforced.

The new agreement also says Icahn will raise $750 million in cash for TWA's budget by issuing debt securities through the investment banking firm Drexel Burnham Lambert Inc.

The TWA statement said Drexel is "highly confident" of its ability to place this financing.

Reports about renegotiation of the Icahn-TWA deal had circulated on Wall Street for several weeks, and the uncertainty over what TWA's minority stockholders might receive for their shares drove TWA's stock price steadily lower. It closed at $15.125 a share today on the New York Stock Exchange, down 75 cents from Thursday. The stock traded at $22.75 a share in late November.

"Although I believe strongly in the future of the airline industry in general, and TWA in particular, I also believe that this is not the time for TWA to be decreasing its cash position by payments to stockholders, including myself," Icahn said in a statement.

"With these funds" from the new securities, Icahn said, "I believe that TWA will be a strong and viable competitor capable of withstanding the current fare wars, the adverse impact on international traffic caused by recent acts of terrorism, and any disruptions that may result from a possible strike by TWA's flight attendants who thus far have not agreed to give TWA concessions so that its costs will be comparable to industry averages."

TWA President Richard Pearson and two other outside directors, W. L. Hadley Griffin and Morton I. Sosland, said in a statement: "We believe, in conjunction with our financial and legal advisers, that under the circumstances this is the wisest course for TWA to pursue at the present time."

As part of the new agreement, Griffin and Sosland -- two of the three non-Icahn designees on the board -- resigned as directors.

Icahn appointees now constitute a majority of the TWA board.

Under the exchange offer, expected to begin in February after the financing program is completed, TWA will offer to swap $24 face amount of its $7.25 preferred stock for each share of common stock. The offer is limited to a maximum of 12 million outstanding shares.

Icahn and his affiliates agreed not to tender any of their shares in the exchange offer. Icahn also pledged not to sell his TWA shares prior to Sept. 30, 1987, without giving all TWA stockholders the chance to participate in such a sale at the same terms.

In a further move to strengthen the company, TWA said the new arrangement with Icahn would allow the airline to keep its PARS reservation system.