Prince Charles and Princess Diana reached final agreement on the terms of their divorce today, reducing what had begun as a storybook union, sealed with a kiss on the Buckingham Palace balcony, to drab details of cash that will soon change hands and custody arrangements for their children.

The dissolution of the royal marriage -- which lasted nearly 15 years, but was unhappy for half that time -- was announced by the couple's lawyers, who said the relevant papers would be filed in court Monday. By the end of August, the divorce should be final.

No monetary details were released, but the British press reported that Diana will receive a lump sum of between $22 million and $27 million. She will also receive about $600,000 a year to run her private office, according to reports.

But in what appeared to be a significant defeat, she will lose the title "Her Royal Highness," which as recently as last week she was still battling strenuously to keep. She will be known simply as Diana, Princess of Wales -- and it will be up to individuals whether they choose to curtsy or bow when they meet her.

Diana will continue to live at Kensington Palace, her West London home, according to a spokesman for the royal family. She and Charles will share custody of their sons, William, 14, and Harry, 11, who both attend boarding school.

The settlement was announced jointly by Charles's blue-blood law firm, Farrer and Co., and Diana's equally high-toned lawyers, Mishcon de Reya. Neither of the principals made any statement about the divorce. Diana spent the day at Kensington Palace with her children and was glimpsed driving off with Lucia Flecha de Lima, the wife of Brazil's ambassador to the United States. Charles was touring a London neighborhood with visiting South African President Nelson Mandela.

It was Queen Elizabeth's unsubtle prodding last December that led to the divorce. After years of embarrassing revelations -- Diana's late-night phone conversations with a male friend who called her "Squidgy," Charles's late-night phone conversations with his mistress Camilla Parker-Bowles, Diana's confessed adultery, Charles's confessed faithlessness -- the queen announced at the end of last year that she hoped they would agree to an early divorce. That "hope" had all the force of a direct order.

But reaching a final settlement was the focus of ill-tempered wrangling between the parties and press leaks, for which officials at Buckingham Palace have blamed Diana and her circle.

One bone of contention has been the inclusion of a clause forbidding Diana to talk about details of the financial settlement. She is reported to have insisted that Charles, too, be formally gagged.

While Diana is hardly a palace favorite, she remains the mother of the second-in-line to the throne. A Buckingham Palace spokesman said that Diana, although no longer a member of the royal family, would continue to be treated as such.

The divorce leaves both Charles and Diana open to remarry. Diana, who recently celebrated her 35th birthday, is said not to have ruled out the prospect of having at least one more child. But in a television interview last year in which she admitted adultery with Guards officer James Hewitt, she claimed to millions of viewers that "a fulfilling job" was better than a man. Charles has a close and continuing relationship with Parker-Bowles, whom Diana reportedly referred to as "the Rottweiler." Charles confessed his adultery with her in an equally high-profile fashion on a TV documentary two years ago.

She is now divorced from her husband, Andrew Parker-Bowles. But any prospect of either Charles or Diana remarrying in the near future nevertheless appears remote, although it was stressed that if Charles did take another wife it would not affect his right to ascend to the throne.

A British constitutional expert, Lord St. John of Sawsley, said Charles's right to the throne has nothing to do with his marital status, and indeed there have been other divorced British monarchs. However, he said, another marriage could cast doubt on Charles's position as titular head of the Church of England.

"If he wished to get married, of which there is no sign, there might be difficulties with his position as supreme governor of the Church of England," he said.

Last year, details of Diana's personal spending were leaked, allegedly by friends of Charles anxious to clarify that despite her carefully cultivated image as one who is never happier than when ministering to the sick and dying, she was in fact an expensive and "high-maintenance" spouse.

Her annual "personal grooming" bill is said to be nearly $250,000, including $18,000 on physical fitness, $15,000 on hair, $12,000 on aroma therapy and $33,000 on beauty treatments.

But some reports suggested she could be almost as well off in real terms as her ex-husband. She is believed to have personal investments of around $7.5 million, which would give her an income of about $375,000 a year. Charles has an income of around $1.5 million a year after he has paid tax and staff. But he is said to have only about $3 million in the bank.

Since the couple separated in December 1992, one of the main unresolved issues was a future public role for Diana, a woman routinely shown by polls to be more popular in Britain than Charles, the future king. Buckingham Palace said today that any future public role for the princess would "essentially be for her to decide." CAPTION: Princess Diana, right, and Lucia Flecha de Lima, the wife of Brazil's ambassador to the United States, leave Kensington Palace by car.