Clients of J. Ezra Merkin, a prominent Wall Street hedge fund manager who invested his investors" money in Bernard L. Madoff's epic Ponzi scheme, will recover more than $400 million under a civil settlement negotiated by the New York State attorney general's office. The deal, the first settlement of a government action against Mr. Merkin, was approved by a New York state judge late Friday, according to people in the office of New York Attorney General Eric T. Schneiderman. The agreement is expected to be publicly announced on Monday. He also will pay an additional $5 million to the state to cover fees and investigative costs, the state sources said. The agreement settles a civil fraud case the attorney general's office filed against Mr. Merkin in April 2009. That case, initiated by Andrew M. Cuomo, who has since become governor, accused Mr. Merkin of deceiving his clients by collecting hundreds of millions of dollars in management fees when, in fact, he was simply handing money over to Mr. Madoff, not managing it himself. The settlement, however, may face a legal challenge from the bankruptcy court trustee, who is collecting money to compensate all eligible victims of the Madoff fraud. In March 2009, Mr. Madoff confessed that he had operated a long-running Ponzi scheme, one that affected thousands of investors around the world. Cash losses in the scheme are estimated at a minimum of $17 billion, but the paper wealth wiped out by the fraud totaled more than $64 billion. Mr. Madoff is serving a 150-year sentence in a federal prison in North Carolina. The attorney general's settlement with Mr. Merkin would benefit investors in his four private funds: Ariel Fund Ltd., Gabriel Capital L.P., Ascot Fund Ltd. and Ascot Partners. Mr. Schneiderman has previously said that more than 10 percent of the money invested in those funds belonged to charities and other nonprofit institutions, including Bard College, New York Law School, the Harlem Children's Zone and the Metropolitan Council on Jewish Poverty in New York. The complex formula for distributing the money to Merkin investors calls for those who were not aware of Mr. Merkin's ties to Mr. Madoff to recover a larger percentage of their losses than those who knew of Mr. Madoff's involvement. The funds will be distributed under the direction of David Pitofsky and Bart Schwartz, the receivers overseeing the liquidation of the Merkin funds, with Justice Richard B. Lowe III of the New York State Supreme Court, who approved the settlement, as the ultimate arbiter. Mr. Merkin, an investment manager and philanthropist who was well-known on Wall Street and served for many years as the president of the Fifth Avenue Synagogue, has denied any knowledge of Mr. Madoff's fraud and any deceptive dealings with his own investors. Mr. Merkin has also been sued in federal bankruptcy court by Irving H. Picard, the bankruptcy trustee liquidating Mr. Madoff's estate for the benefit of his victims. That lawsuit seeks the recovery of $500 million to be added to the general fund administered by Picard that will ultimately be distributed to all eligible Madoff investors. One person associated with Mr. Schneiderman's office said on Sunday that the Merkin settlement was "structured in a way that didn't require the approval" of Mr. Picard. But that conclusion is likely to be disputed by lawyers for Mr. Picard, who have privately been arguing against a separate state settlement with Mr. Merkin for more than a year. In their view, Mr. Merkin's management fees were paid with cash that Mr. Madoff stole from other people and paid out to Mr. Merkin's investors. Therefore, they contend, any settlement with Mr. Merkin should benefit all eligible Madoff victims, not just Mr. Merkin's clients. Moreover, Mr. Picard is determined that all Madoff claims should be handled through the federal bankruptcy court, not through piecemeal litigation that benefits only small groups of investors. On those grounds, Mr. Picard's lawyers have already gone to court to challenge a number of other separate legal actions involving Madoff claims. This settlement is likely to be additionally contentious because it involves indirect Madoff victims, those who invested in a feeder fund that was a direct Madoff customer. The federal bankruptcy judge handling the Madoff matter has ruled that indirect investors are not eligible for direct compensation and must wait to be compensated by the fund through which they invested. The New York State settlement seems to short-circuit that process for the subset of indirect investors who invested with Mr. Madoff through Mr. Merkin's funds. Amanda Remus, a spokeswoman for Mr. Picard, did not immediately respond to requests for a comment on the settlement.