The City of Philadelphia must pay nearly $900,000 to the Boy Scouts for legal fees after failing to evict the scouts from their headquarters over antigay policies.

A federal judge on Wednesday denied the city's request for a new trial in a case that has lasted nearly a decade. Mayor Nutter said the city was reviewing the opinion, calling the $877,122 bill a "significant expense."

The city tried to avoid a giant payout by proposing a deal last year in which the local Cradle of Liberty scouts group would buy the building at 22d and Winter Streets for $500,000 and forgive the legal fees. But legislation to authorize the deal languished in City Council after gay-rights advocates complained.

Bill McSwain, the scouts' attorney, said the scouts "would have been happy" with the deal.

The city tried to evict the scouts over the national organization's policy of excluding gays, but the scouts sued. Ever since the scouts' legal victory in 2010, the two sides have been trying to work out a settlement.

Nutter did not say what options the city was considering. But he stressed that the city did not condone the scouts' national exclusionary policy.

"We do not as a city support that kind of behavior," he said. "We've tried to take a number of steps to get the Boy Scouts out of a city-related building."

McSwain said the local chapter had never discriminated.