NEW YORK – A deal has been reached to divide up the $300 million estate of the reclusive heiress Huguette Clark, a shy artist who lived her last 20 years in New York hospitals while her palatial homes sat empty.

Huguette Clark in the 1940s. Born in 1906, the youngest daughter of one of the richest men of the Gilded Age, her fortune was divided in a settlement filed Tuesday in a New York court.

The settlement was signed in the middle of the night and delivered to the judge in Surrogate's Court in Lower Manhattan on Tuesday morning, when jury selection in a trial over Clark's will had been scheduled to resume. Surrogate Judge Nora S. Anderson accepted the deal, effectively ending the trial before it began, and will formally approve it at a later hearing. But the deal drew an appeal from one group that was cut out of the negotiations, meaning it could have to be redrawn.

The deal gives $34.5 million to Clark's relatives, although her will stated emphatically that they should receive nothing. These relatives are the great-grandchildren and great-great-grandchildren of Huguette's father from his first marriage. Her father — W.A. Clark, the copper miner and former U.S. senator from Montana who also founded Las Vegas — left equal shares of his fortune to all of his surviving children: Huguette and four of her half-siblings.

The settlement sets up an arts foundation controlling the Clark family's $85 million California summer home at Santa Barbara. That charity is the largest beneficiary of the will, as Clark directed, but with a twist: In the settlement, the foundation isn't set up in California but in New York, with the New York attorney general forming the first board of directors. Seats are reserved for the Santa Barbara community, and Clark relatives also get a seat.

After Huguette Clark died in 2011 at age 104, 19 relatives challenged her will, claiming she was mentally ill and had been defrauded by her nurse, attorney and accountant. No one was charged with any crime after an investigation by the district attorney's office, but enough questions were raised that the case is being settled before the jury trial, which could have lasted six to eight weeks. The relatives, who last saw her in 1957 and most of whom never met Clark, will take home the full $34.5 million, as the estate will pay the relatives' taxes and $11.5 million in legal fees. Altogether, about $25 million in legal fees are included in the settlement.

The big loser in the settlement is Clark's nurse and companion, Hadassah Peri, who was the daytime private-duty registered nurse for 20 years while Clark lived in Doctors Hospital and then Beth Israel Medical Center. Peri had received $31 million in gifts while Clark lived, and was in line for a share of the will, approximately $30 million before taxes. (Read the will.) But under the settlement the nurse receives nothing from the will and has to pay back $5 million to Clark's estate. The advantage for the nurse is that the settlement stops attempts to recover even more of the gifts. The attorney general's office took the position that gifts to a caregiver were excessive and presumed to be the product of undue influence. Peri, 63, an immigrant from the Philippines, worked 12 hours a day, seven days a week, for many years, before moving to eight-hour days. She was paid $131,000 a year. Her attorney will receive $1.5 million in fees.

The attorney for the nurse, Harvey Corn, read this statement to reporters: "The Peri family is very happy to contribute to the settlement of the litigations involving Madame Clark in the hope that it will allow Madame Clark to retain whatever privacy that she has left. The Peri family was blessed to have met Madame Clark and she will always be in their thoughts and prayers."

Huguette (pronounced "oo-GET") Marcelle Clark was the youngest child of former U.S. Sen. William Andrews Clark (1839-1925), one of the copper kings of Montana, a railroad builder and one of the richest men of the Gilded Age. Huguette, born in Paris in 1906, was a painter and doll collector who spent her last 20 years living in simple hospital rooms. She attracted the attention of NBC News in 2009 because her fabulous homes in Connecticut, California and New York sat unoccupied but carefully maintained. (See all the stories in the NBC series.)

She signed her last will in 2005 when she was 98 years old. Medical records and her telephone conversations and correspondence suggested that she was still quite lucid. At first she signed a will leaving a promised $5 million gift to her nurse, and all the rest went to her relatives. The relatives were not named in that first will, which said all the rest of her fortune would go to whoever would inherit if she died without her will. (Read the earlier will.) Six weeks later, she signed a more detailed will naming specific beneficiaries and cutting out the family.

The settlement was shepherded by the office of New York Attorney General Eric Schneiderman. The head of the attorney general's charities bureau, Jason Lilien, has told parties in the case that his office was working aggressively to protect the charitable interests. That office made sure that the beneficiaries in confidential relationships with Clark — her nurse, attorney and account — received nothing.

Which Bellosguardo Foundation?Clark's will established a Bellosguardo Foundation to foster the arts and stated that it should receive the property known by that name, the Clark summer home overlooking the Pacific at Santa Barbara, as well as Clark's art collection and cash.

The deal reached Tuesday provides much of what Clark intended to the foundation, but made changes that led to an appeal.

One of the named trustees, Clark's California attorney, established a Bellosguardo Foundation in California, but the settlement left that group out of the deal. Instead a new Bellosguardo Foundation will be formed in New York. The judge had allowed the California group to take part in the court case in New York right up until it objected to the settlement — at which point the relatives objected to the California group being in the case. The legal quandary is this: The will set up the foundation, but until the will is determined to be valid by a judge or jury, does the foundation exist, and can it be represented in court? The law on this question is thin. Judge Anderson ruled after a secret hearing that the California foundation can't be represented. (Read the decision.) The California group filed an appeal on Monday.

That question could ultimately end up in federal court. If the New York appeals court doesn't allow the California group to participate in the settlement, the issue could be revisited in a California court when the New York Bellosguardo Foundation tries to take control of the property. That conflict between states could ultimately become a federal case.

In addition to the Clark summer home, valued conservatively at $85 million, the new Bellosguardo Foundation would receive Clark's $1.7 million doll collection, which had been left to the nurse, and $4.5 million in cash.

The foundation also could face liabilities. The settlement assumes that the Internal Revenue Service will cooperate by lowering the estate's tax bill. Clark was so relentlessly generous to her staff and friends that she died owing the IRS $82 million in gift taxes, with the bill rising $9,000 per day from penalties and interest. The settlement is premised on the hope that the IRS will forgive the penalties, estimated at $16 million to $18 million, because the settlement mostly benefits charities. If the IRS insists on collecting the penalties, that bill will lower the amount flowing to the foundation and could ultimately require it to sell the California property.

Details of the deal

Other elements of the settlement proposal include:

The attorney for the relatives, John R. Morken, and his law firm Farrell Fritz would receive $11.5 million in fees, paid from the estate. Usually a settlement would pay a certain amount to the parties, who would pay their own lawyer. By having the estate pay the legal fees, it generates a tax break, if the IRS cooperates by considering the legal fees a tax-deductible expense.

Clark's attorney, Wallace "Wally" Bock, 81, and her accountant, Irving H. "Irv" Kamsler, 66, would receive nothing. They had been ready to give up their $500,000 bequests to allow them to testify for the will. More important, they lose their chance to be executors of her estate, a role that would have paid them each about $3 million. Criminal investigation of Clark's finances found no basis to charge either with a crime.

Bock's attorneys, from the firm of Holland & Knight, would receive $11.5 million in fees for representing the will, on top of about $2 million already paid.

Clark's goddaughter, Wanda Styka, 70, would receive $3.5 million. The daughter of Clark's painting instructor, Tadé Styka, she hadn't seen Clark since she was a child in the 1950s but sent gifts and wrote letters in a flowing cursive that Clark liked to show off to doctors.

The Corcoran Gallery of Art in Washington, D.C., would receive at least $10 million. The favorite museum of the Clark family, the Corcoran had been left a Monet painting from the "Water Lillies" series, valued at $25 million, but took a position against the will, siding with the Clark relatives and claiming that Clark was incompetent. The Corcoran also gets a seat on the board of the Bellosguardo Foundation.

Beth Israel Medical Center, where Clark lived for two decades, would receive its bequest of $1 million — but there's a catch: The Clark relatives, the foundation and the Corcoran have a right to increase their take by trying to recover money from the hospital, which received millions in gifts from Clark while she lived there for two decades. The largest gift was a Manet painting worth $3.5 million.

Several beneficiaries would get exactly what was directed in the will: Clark's doctor, Henry Singman, would receive $100,000. Clark's personal assistant and manager of her Fifth Avenue apartments and doll collection, Chris Sattler, would receive $500,000. C. John Douglas III, who manages her California property, would receive $253,700, or two years' pay. Anthony Ruggiero, the property manager in Connecticut, received one year's pay, $16,800.

Clark's papers would go to UCLA's William Andrews Clark Memorial Library in Los Angeles, which was donated by Huguette's half-brother W.A. Jr. in honor of their father.

Most of the fine art work owned by Clark would be sold to fund the settlement.

Many paintings already at Bellosguardo would stay with the house and the foundation, which also would receive the paintings created by Clark, a trained artist.

Statements on the caseThe spokeswoman for the attorney general, Melissa Grace, released this statement: "After more than two years of litigation, Attorney General Schneiderman's Charities Bureau has brokered a settlement that will ensure that Huguette Clark's charitable wishes are fulfilled, allowing the bulk of Mrs. Clark's wealth to go to charity instead of being wasted on legal costs. The arts foundation that Mrs. Clark envisioned will be created, with the gracious and historic Bellosguardo mansion in Santa Barbara, California, at its center."

The mayor of Santa Barbara, Helene Schneider, said in a written statement she would create a working group to help her nominate directors for the Bellosguardo Foundation board. "The negotiations led by the New York attorney general’s office ensures that the Santa Barbara community is well represented by creating the foundation board of directors in this manner. I believe the attorney general’s office worked to follow Ms. Clark’s wishes to the best extent possible under the circumstances, and respected the Santa Barbara community’s strong desire to see this property utilized in the public’s interest. The ultimate goal is to open the Bellosguardo house and gardens to the public as a center that will foster and promote the arts. I believe this settlement gives our Santa Barbara community an amazing opportunity to create a magnificent organization that will significantly add to our strong artistic and cultural heritage."

The Clark relatives released a statement through their attorney: "The Clark family is extremely gratified by the settlement announced today. First, it honors our Aunt Huguette and her legacy. Second, it accomplishes our primary motivation for challenging the will: focusing attention on the issue of elder abuse. By removing Wallace Bock and Irving Kamsler from their positions as executors, and having Hadassah Peri return a significant amount of money, the settlement sends a strong message that those entrusted with the care of the elderly will be held accountable for their actions. We applaud the establishment of the Bellosguardo Foundation, and look forward to contributing to its success, continuing our family’s more than 100-year tradition of supporting the arts in a meaningful way. We also appreciate the Corcoran’s firm stance in this matter, and that it is receiving a substantial bequest from Aunt Huguette."