NEW YORK — J.C. Penney and its largest shareholder, William Ackman, have made a deal that sets terms for allowing him to unload his stake in the company in an orderly manner.The agreement, filed Friday with the Securities and Exchange Commission, comes days after Ackman resigned from the 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 a 17.7 percent stake, or 39 million shares, in Penney. Under the deal, Ackman can make up to four requests to the company to register the sale of his shares. Each request must be for at least 5 million shares and the deal terminates when he owns less than 5 percent of the company’s stock. Pershing Square is not legally able to start selling its stock until at least Tuesday, when Penney is scheduled to report its second-quarter results, because Ackman was privy to confidential financial information as a board member. The deal gives Penney some control over the timing of sales. Deborah Weinswig, a retail analyst at Citi Research, said in a note to investors that beginning Nov. 20, Penney may postpone granting a registration to Pershing Square under the agreement or require Pershing Square to refrain from disposing of Penney’s stock for no more than 90 days, based on an analysis of the filing. Penney is limited to no more than three such blackout periods in 12 months and no more than 90 days blacked out in entirety. The Plano-based retailer can also delay a registration if the board determines that it “would materially impede, delay or interfere with any material transaction” or if Penney possesses material nonpublic information that would not be in the best interests of the company if disclosed. “In our view, the agreement signals that Pershing Square is willing to sell its stake in the company, although it will be done in an orderly fashion and over a period of time,” Weinswig wrote. “We believe that this could serve as an overhang on the stock as investors wonder if Pershing Square will exit its stake.” In addition, she said, another big investor, Vornado Realty Trust, whose chairman, Steve Roth, is a Penney board member, could unload more shares. Vornado, which owns and manages office buildings, malls and other commercial real estate, sold more than 40 percent of its Penney shares in March. Vornado still holds 13.4 million shares, or 6.1 percent. The agreement, filed with the SEC, caps a tumultuous two weeks for Penney and Ackman. Ackman went public last week with statements that he’d lost confidence in the board and that Chairman Thomas Engibous should be replaced. Ackman and the board were also bickering over how quickly the company should replace CEO Mike Ullman. On Tuesday, Ackman resigned from the board, and Penney named Ronald Tysoe to fill the seat. Tysoe is former vice chairman of Federated Department Stores, now Macy’s. Penney will name an additional director in the near future.