NEW YORK (AP) J.C. Penney Co. and its largest shareholder, William Ackman, have made a deal that sets terms for allowing him to unload his stake in the company.

The agreement, filed with the Securities and Exchange Commission Friday, comes days after Ackman resigned from Penney's board as part of a deal to resolve an unusually public battle between the activist investor and the struggling department store.

Ackman's Pershing Square Capital Management has 17.7 percent stake in Penney.

Under the deal, Ackman can make up to four requests to the company to register the sale of his shares. The agreement terminates when he owns less than 5 percent of the company's stock.

Pershing Square is not legally able to sell its stock until at least Tuesday, when Penney is slated to report its second-quarter results, since Ackman is privy to confidential financial information as a board member.

The agreement, filed with the SEC, caps a tumultuous two weeks for Penney and Ackman.

Ackman went public last week with statements saying he'd lost confidence in Penney's board and that Chairman Thomas Engibous should be replaced. Ackman and the retailer's board also were bickering over how quickly the company should replace CEO Mike Ullman.

On Tuesday, Ackman resigned from the board, and Penney named Ronald Tysoe as a director to fill Ackman's seat. Tysoe is former vice chairman of Federated Department Stores Inc., which is now Macy's Inc. Penney will name an additional new director in the near future.

Ackman said in a statement Tuesday that the moves were "the most constructive way forward" for the Plano, Texas, company and all parties involved.

Penney's board also reiterated its support for CEO Ullman, who returned to that job in April. Ullman had previously served as Penney CEO from 2004 to 2011.

Ackman's departure doesn't do much to reverse Penney's declining business, which is trying to lure back shoppers turned off by a reinvention plan formulated by a former CEO backed by Ackman.

Ullman had replaced Ron Johnson, who was ousted as CEO after 17 months because his radical makeover led to massive losses and sales declines.

Ackman joined Penney's board in February 2011 and was the one who pushed the board to hire Johnson, a mastermind of Apple Inc.'s successful stores. The hope was Johnson could inject new energy into a tired company.

Penney's stock fell 45 cents, or 3 percent, to $13.38 in morning trading.