A federal judge ruled here yesterday that in the interest of air safety American Airlines may legally refuse to hire new pilots over the age of 40.

U.S. District Judge Charles R. Richey rejected the arguments of a 43 year-old man whom the airline had refused to hire as a flight officer. The man had been joined in his suit against the airline by the Labor Department, which said the airline was violating the Age Discrimination Employment Act that protects persons between 40 and 65 from discriminatory hiring practices.

Richey found, however, that the airline's refusal to hire persons over 40 as pilots was allowable in this instance because it was a "bona fide occupational qualification" connected with air safety.

"Indeed, the court finds that safety is the essence of American's business," Richey ruled in a 27-page opinion. "In some cases, the individual interest in being free of employment discrimination on account of age must give way to the societal interest in having the safest air transportation system possible."

Edward L. Murnane, a former Navy and Coast Guard aviator, was 43 years old when he applied for the entry-level American Airlines pilot job of "flight officer" in 1976. He never proceeded further in the application process, and complained that he was being discriminated against because of what he called an "industry-wide reluctance to hire older pilots."

Richey noted that American has a policy of hiring as flight officers only persons whom it can eventually promote to copilot, and then captain.

Captains must now retire at the age of 60 -- although there are some pilots and others who are seeking legislation to erase that mandatory retirement age.

The average age of qualified airline pilots is around 42, according to one industry group.

American argued that it should be able to train its pilots to its own standards to carry out its duty to conduct its business with the highest degree of care for its passengers, and that to be forced to hire persons over 40 years old "will increase the likelihood of risk of harm to passangers and crew."

"The court finds this argument persuasive," Richey said. He noted that 90 percent of air accidents are attributablle to "pilot error" and that if an American Airlines pilot errs, "the death or injury of as many as 400 passengers and crew, and the destruction or damage of a multimillion-dollar aircraft, can result."

Richey said there is "credible and persuasive evidence" that the incidence of aviation accidents decreases as the age of the pilot increases, "a function of the amount of experience" acquired by the pilot.

The average American pilot is hired about the age of 30, and under the company's present hiring policy, a 55-to-59-year-old captain has been flying as a captain with the airlines for at least 10 to 15 years, Richey said.

"The couurt concluded that if American were to hire pilots above the age of 40 at the time of hiring, it would not be possible for them to acquire this essential experiience before they are forced to retire by the (Federal Aviation Administration's) age 60 rule," he added.

"American should be able to apply a reasonable general rule in order to minimize the risks of the disastrous consequences of an airline accident," Richey said.