NEW YORK (AP) _ American Airlines said Thursday night it had reached an agreement to buy three Trans World Airlines routes into London for $445 million.

American ended up paying TWA owner Carl Icahn the entire price it had originally agreed to pay for all six of TWA's routes into London's Heathrow Airport, considered the dominant gateway to Europe.

Icahn was able to hold out for the full amount after the Transportation Department ruled last week that American, the largest U.S. carrier, could only have three of the routes, originating out of New York, Los Angeles and Boston.

Analysts say American was pressured by a need to keep up with United Airlines, the nation's second-largest carrier. United began flying into Heathrow last month on routes it purchased from Pan American World Airways, another cash-starved weakling in the struggling air travel industry.

''It is extremely important to American to operate these three key routes - plus Chicago-Heathrow and Miami-Heathrow - during the peak summer 1991 season,'' American Chairman Robert L. Crandall said in a statement. American hopes to begin serving the routes on July 1.

The deal still faces a legal challenge from TWA unions who contend the route sales effectively will kill TWA. But Crandall said that objection, filed with a federal appeals court, is ''without merit.''

American had initially agreed to pay $445 million for six TWA routes into Heathrow. The other three originate in Philadelphia, Baltimore and St. Louis.

The three routes that American was allowed to buy carried more than 80 percent of the traffic.

Both carriers were under pressure to reach a deal quickly. TWA is in desperate need of cash. American said it needed to act fast, saying that if it did not reach an agreement on the routes by May 15 it would not be able to start serving Heathrow by its target of July 1.

The British government only allows two U.S. carriers to serve Heathrow. It took months of delicate talks before the U.S. government could persuade the British to let American and United replace TWA and Pan Am.