A Philadelphia judge on Friday ordered the immediate reinstatement of Inquirer editor William K. Marimow, overturning a firing that exposed deep divisions among the newspaper's owners and sparked an ugly public battle for control of its parent company.

In a late-afternoon ruling, Common Pleas Court Judge Patricia A. McInerney declared that Marimow's Oct. 7 firing violated the contract rights of Lewis Katz, one of two co-owners who opposed his dismissal.

George E. Norcross III, who leads a rival faction of owners and became a defendant in the lawsuit filed by Katz and H.F. "Gerry" Lenfest over the firing, vowed to appeal.

Norcross and the three other partners said in a statement that restoring Marimow would reignite the stalemate among owners and lead to "chaos" or paralysis for Interstate General Media. With nearly 1,800 employees, the company also operates the Philadelphia Daily News and Philly.com.

Marimow, 66, arrived in the Inquirer newsroom shortly before 5 p.m. to cheers, applause, and hugs from the staff.

"Bill, where have you been?" quipped sports editor John Quinn.

In an interview, Marimow praised Katz, Lenfest, and their lawyer, Richard A. Sprague, and said he was committed to "a vigorous, independent" news organization.

"This is the only job I ever really wanted after I left reporting," said Marimow, who won two Pulitzer Prizes as a reporter for The Inquirer and had two previous stints as its editor, the last starting in May 2012. "It is great to be back."

Publisher Robert J. Hall, who fired Marimow after he claimed Marimow refused to implement changes to the paper and oust certain staffers, could not be reached for comment.

The judge's ruling came after four days of testimony and argument since Nov. 13, and weeks of court filings and public - and sometimes personal - volleys that laid bare the feud among the six millionaires who paid $55 million and formed the company last year.

Katz contended that Marimow's dismissal was a breach of the partnership contract that called for him and Norcross, as managing partners, to jointly approve all major business decisions at the company.

Norcross countered that the publisher had unfettered authority to hire and fire the editor, and that Katz had broken their agreement by meddling in newsroom affairs.

In court filings and testimony, each side accused the other of acting to protect or preserve personal ties to the news operations. Katz's companion is Inquirer city editor Nancy Phillips and his son is a company director. Norcross' daughter, Alessandra, is also a director and had clashed with some Inquirer editors in her role of managing operations at Philly.com.

In her five-page ruling, the judge said the agreement was ambiguous on whether the hiring and firing of newsroom personnel constituted a business decision. McInerney also said she was "disturbed" by the setup and its built-in conflict, but ultimately concluded that Katz's rights had been ignored.

"Mr. Katz had a clear right to vote on the firing of Mr. Marimow," she wrote.

Katz said he was heartened by the decision but knew it would not end the dispute.

"It's really time now to come up with the best way to either bring this partnership together or break it apart," he said in a brief interview. "Nobody really wins whenever you get involved in a family squabble."

Katz said it was time to look for "the best way forward" for the company.

It was unclear what that way will be.

Katz and Lenfest had unsuccessfully petitioned the judge to remove Hall, whose contract had been extended until Dec. 31. Marimow's contract runs though April 30, 2014.

And McInerney predicted ongoing trouble making decisions on those two key leadership positions, given the animosity between Katz and Norcross.

"The court further recognizes," she wrote, "that the granting of said petition solely resolves the discrete and narrow issue pending before this court and does not resolve nor necessarily advance the likelihood of resolution of any other issues in the operation of The Inquirer."

Each faction had offered to buy the other out, and the sides spent hours this week in closed-door settlement talks with the judge, but those negotiations stalled.

In a statement released by their spokesman, Dan Fee, Norcross and the others promised an "expedited" appeal, although the statement did not elaborate.

The statement said the ruling would lead to chaos and open the newsroom decisions to the owners' wishes.

"We believe today's decision is wrong and will harm the journalistic independence and operations of the newsroom," it said.

Asked about the future for him and the news organization, Marimow said: "The answer is, I don't know. I intend to work as hard as I can and edit as well as I can for the future. Whatever the future holds, as long as The Inquirer, Daily News, and Philly.com are in the hands of people who believe in a vigorous, independent press, this region will be well served, whether I am here or not."