NEW YORK -- Airport security officers hired to guard illegal aliens marked for deportation were routinely extorting money and sex from them in exchange for engineering the aliens' escape, according to a federal complaint filed yesterday in Brooklyn.

The scheme, uncovered after a 10-month investigation by federal agents at John F. Kennedy International Airport, involved 21 employes of Wells Fargo Guard Services and six "civilians" who recruited aliens for the shakedown. All 27 were arrested and arraigned in a Brooklyn federal courtroom.

The complaint detailed 70 such cases between June 1985 and last July, all involving citizens of Jamaica or the Dominican Republic. But the real number was "much, much higher," U.S. Attorney Andrew J. Maloney said, and the scheme had likely been operating for years.

Maloney said that the aliens were charged between $2,000 and $10,000 each to be set free and that in some cases female aliens were freed in exchange for "sexual favors." They were often held in overcrowded conditions and denied food, he said.

Under the U.S. deportation system in effect at the time, aliens were turned over to security guards at international airports to be placed aboard the next available flight to their homeland. Federal regulations required the airlines to pay for the guards, and at Kennedy airport the contract was awarded in 1980 to Wells Fargo, a division of Baker Industries of Parsippany, N.J.

A Baker Industries spokesman said that the Wells Fargo office at Kennedy was closed in 1986 and that the company had "cooperated fully" with federal investigators since the probe began.