American Airlines backed away from the brink of a bankruptcy filing yesterday after the flight attendants' union agreed to substantial wage and benefit cuts. The agreement came a day after American's former chairman and chief executive, Donald J. Carty, resigned because of stinging criticism over executive benefits.

Also yesterday, the Transportation Department filed a complaint against the airline, accusing it of discriminating against passengers thought to be Muslims or of Middle Eastern or Southeast Asian descent in the three and a half months after the attacks of Sept. 11, 2001. The airline denied the charges and said its crew members were trying ''to be vigilant.''

As dawn broke yesterday, it looked as if AMR, the parent company of American, would have to file for bankruptcy protection from creditors. The previous evening, the boards of its pilots' and ground workers' unions had agreed to take $1.28 billion in annual concessions, but the flight attendants had held out.

Gerard J. Arpey, the new chief executive of American, then met with four members of the flight attendants' board, hours after donning Mr. Carty's mantle. The union also received frantic calls from two members of Congress. Finally, around noon yesterday, the flight attendants' union said that its board had voted 13 to 5 to take concessions worth $340 million a year.

That was the final piece of $1.62 billion in concessions that American, the world's largest airline, said it needed from its unions to avoid bankruptcy. It also capped an extraordinary week for the company, in which Mr. Carty was humbled by the rancor of organized labor and haunted by his decision not to disclose during negotiations that AMR's board had approved new executive benefits last year. Those were cash bonuses of up to twice annual base salary for seven executives for staying until 2005, and a $41 million pretax payment into a trust fund set up to protect the pensions of 45 executives in the event of bankruptcy. The wage and benefit cuts from the unions go into effect on May 1. ''It's my hope that today represents a new opportunity for American Airlines and its employees,'' John Ward, president of the Association of Professional Flight Attendants, said yesterday in a news conference in company headquarters in Fort Worth.

Next to him, Mr. Arpey warned that ''by any measure, we have our work cut out for us; we are not out of the woods yet.''

Several analysts said that American's labor cuts go only part way toward making the company a viable airline. American will still have to get significant savings from its aircraft lessors and suppliers, they say, as well as figure out a way to overhaul a broken business model. Jim Corridore, an analyst at Standard & Poor's, said American could still file for bankruptcy in 6 to 12 months.

Furthermore, many union members will probably feel bitter over having to take cuts in the face of Mr. Carty's actions.

''The flight attendants I know feel they have been sold down the river again,'' said Stephen Baumert, a flight attendant based in Miami who writes a newsletter for nearly 600 workers. Mr. Baumert said many employees remained angry at the board's compensation committee for approving the executive benefits and were suspicious of Mr. Arpey since he was a recipient of those benefits. Until yesterday, he was president and chief operating officer.

The company has canceled the cash bonuses but kept its $41 million payment to the executive pension trust fund.

American must also now deal with the discrimination complaint filed yesterday by the Aviation Enforcement Office of the Transportation Department. The office charged the airline with violating federal law by turning away -- on the basis of race or religion -- 10 properly ticketed passengers who had passed security checks.

The department said these incidents took place between Sept. 11, 2001, and the end of that year, with most occurring after Sept. 21, when the Transportation Department warned airlines that they could not discriminate against passengers.

The Aviation Enforcement Office said it began an investigation of American after hearing complaints from travelers and reviewing internal company reports documenting people removed from flights or not allowed to board their scheduled flights. The office said it filed its complaint after it failed to negotiate a settlement with the company.

The case will be heard by an administrative law judge. If found guilty, American could owe up to $65,000 in civil penalties, in addition to penalties for any further violations discovered during the proceedings. The Aviation Enforcement Office is also asking the judge to order American to refrain from discriminatory practices in the future.

Tim Wagner, a spokesman for American, said in a written statement that the nation was on alert during that time and that employees were following the government's instructions to be watchful.

Regarding labor matters, American won its concessions after angry union leaders met with Mr. Carty in a Dallas hotel on Wednesday and held board votes the next day. The unions had already voted last week to hand over $1.62 billion in concessions, but refused to sign off on those after learning that Mr. Carty held off disclosing the new executive benefits until two of the unions had voted on April 15 and a third one was finishing. On Wednesday, union leaders negotiated less costly concessions that provided for five-year rather than six-year contracts and a new bonus plan.

Most workers would take pay cuts of 15 percent to 21 percent and thousands of employees would be laid off.

On Thursday, as AMR's board was asking Mr. Carty for his resignation, the boards of the Transport Workers Union and Allied Pilots Association agreed to take concessions. But the board of the flight attendants' union rejected its share of concessions because American said the union could not hold a broad membership vote on the new contract, said one union board member who spoke on the condition of anonymity.

The board ended its conference call at 5:30 p.m., after five hours of debate, he said. Then the board learned that Mr. Carty had resigned, and four members met with Mr. Arpey that night. Representatives James L. Oberstar, a Democrat from Minnesota, and Peter A. DeFazio, a Democrat from Oregon, made calls to union officials. Around 10 p.m., union leaders sent faxes to board members calling for another phone conference the next morning.

What angered many flight attendants in the contract was a provision that would allow American more leeway in calculating paid hours, the board member said. Executives agreed on Thursday night to lighten that provision, the member said, and that swung enough votes. The call ended at 11:30 a.m.

''Today's discussion was very focused, very serious,'' he said. ''We realized the magnitude of the situation.''

As for executive pay, Mr. Arpey had a base salary of $580,000 last year and declined a cash bonus. In March, he and several executives, including Mr. Carty, agreed to wage cuts. His annual base salary as of April 1 is about $500,000. A recently passed federal law giving financial aid to airlines prevents him from taking additional cash compensation until next April.

The company can still give him stock options or restricted stock.

American has not disclosed Mr. Carty's severance pay. Many chief executives have recently received what are perceived as generous termination packages. But Brian Foley, an executive pay consultant, said that AMR's board would have to be careful.

''There are a variety of constraints on what they can pay,'' he said. ''They have to watch public opinion, union opinion, shareholder opinion.''