For almost 20 years, a group of parrots and their owner lived at the Rutherford, a co-op apartment building in the ritzy Gramercy Park neighborhood of Manhattan.

For almost as many years, the neighbors complained. The parrots shrieked and squawked, they said. The parrots shouted human words, but not clearly enough for the neighbors to follow their conversations. The parrots seemed to generally drive everyone mad.

After years of complaints, the chorus of caws and cries became unbearable. So the building’s co-op board moved to evict the woman who cared for the animals, Meril Lesser.

In response, Ms. Lesser said her parrots — three birds named Ginger, Layla and Curtis — were emotional support animals who also cared for her.

That set off a bitter and complicated legal dispute that ended last week when the federal government announced a settlement that it said imposed the largest ever financial penalty on a building that had denied its residents’ rights to service animals.

According to the settlement, approved by Judge Jennifer H. Rearden on Aug. 16, the building will pay Ms. Lesser $165,000 in damages and will have to buy her apartment for $585,000. The decree said there was “reasonable cause” to believe the building had discriminated against Ms. Lesser and later retaliated against her.