A Common Pleas Court judge has ruled that the Cozen O'Connor law firm cannot forgive nearly $450,000 worth of legal work done for U.S. Rep. Bob Brady's 2007 mayoral campaign without violating the city's campaign finance law.

The powerful Center City firm successfully defended Brady, also head of the city's Democratic party, against rival Tom Knox's effort to get him kicked off the ballot in the 2007 mayoral primary, eventually won by Mayor Nutter.

Cozen sued the city's Board of Ethics in 2008, challenging its opinion that Brady had to raise the money to pay his legal bills within the limits for mayoral races - $5,000 for individuals and $20,000 for political action committees at the time. The Board of Ethics oversees the city's campaign finance rules.

Two lower courts upheld the board's decision, but the state Supreme Court ruled last year that Cozen could seek a judgment on whether the firm could forgive the debt - $448,468 owed by the Friends of Bob Brady Committee.

In an opinion issued Monday, Judge Leon W. Tucker ruled that forgiveness of a debt "constitutes a 'contribution' " and would be subject to the contribution limits.

Tucker also noted this was a question of law that had "a substantial ground for difference of opinion" and that an appeal might ultimately decide the matter.

In a statement, Ethics Board Vice Chair Mike Reed said the ruling "preserves the integrity of the city's campaign finance law."

Contact Troy Graham at 215-854-2730 or tgraham@phillynews.com, or follow on Twitter @troyjgraham.