Late in 1962, a time of tumbling racial barriers and civil rights upheaval, a white doctor from Laurel named Jesse C. Coggins, in the winter of an 88-year life, tinkered with his will. It had long provided for a munificent gift to a Baltimore nursing home, but as segregated America was giving way all around him, Coggins added a proviso.

The Keswick Home would one day receive a hefty bequest from his trust, Coggins wrote, if it used the money to help "white" patients, the only kind the home had ever had. Otherwise, he stipulated, his money was to go to the University of Maryland Hospital, with no race-related condition appended.

Thirty-seven years later, the trust is ready for distribution at last, having been off-limits because of other provisions of the will.

Times have changed further still. A nation has evolved even more. The Keswick Multi-Care Center, as it now is called, has 268 residents, more than a quarter of them black.

And for that reason, a Baltimore City Circuit Court judge has ruled, Keswick will not get the Coggins money, not a penny of a trust that has ballooned to nearly $29 million, a sum that easily exceeds Keswick's $20 million budget. Instead, the judge said, the University of Maryland Medical Center, now the parent of University Hospital, will inherit what will be the largest private gift in the hospital's 176-year history.

Citing a 1970 U.S. Supreme Court case, Judge Joseph H.H. Kaplan wrote that Keswick's loss "is part of the price we pay" for allowing individuals "to exercise a continuing control over assets owned by them at death."

It did not matter that Keswick cannot comply with the will's conditions because contemporary laws bar discrimination. The doctor's intent was clear, Kaplan said. And the result is racially neutral: Keswick's black and white residents suffer the loss of the gift equally.

The Nov. 9 outcome shocked the nursing home. Anticipating it would receive the bequest, officials had built a large residence facility and named it for Coggins, the two other stipulations the doctor had made. It had assumed the anachronistic "white" requirement was unenforceable and last week appealed the ruling, arguing that Kaplan ignored a legal tradition of voiding impossible conditions attached to wills.

"It strikes Keswick as, frankly, unbelievable that in this day and age a court would rule that a clearly illegal and improper provision such as this would be given full effect," said John F. Morkan III, the nursing home's attorney. Keswick, Morkan said, "is being penalized for its nondiscrimination," and University Hospital has "seized upon that" to obtain a windfall through a method "a little tainted."

Shale D. Stiller, attorney for the medical center, said any court probably would have ignored the "white" demand and awarded the money to Keswick--if Coggins had not included a fallback choice, University Hospital. Because he did, Kaplan was able to do what matters most in wills: follow the deceased's clearly stated intent as much as possible.

"We may find it totally abhorrent," Stiller said, "but the important value is that people have earned their money while they're alive, and they ought to be able to do with their money what they want."

Offensive to most ears in 1999, the will's "white" restriction was no rarity. Many wills and property deeds imposed similar conditions. Why Coggins added his can only be surmised. He left no written explanation, and if he offered one verbally to others, no one could be found to share it or to explain another oddity: why his default choice was University Hospital, which he surely knew did not practice discrimination, even if Keswick did.

Born not long after the Civil War, Coggins graduated from the College of Physicians and Surgeons in Baltimore, spent nine years at Spring Grove State Hospital and, in 1905, opened a sanitarium in Laurel, according to court papers. The Laurel facility--now long gone--treated patients suffering from alcoholism or mental illness until 1950, when it became a hospital for elderly women, with Coggins still at the helm.

Over the years, he referred many patients to Keswick, now a modern complex of several buildings on a seven-acre campus in the Roland Park neighborhood of Baltimore, northwest of downtown. Perhaps for that reason, Keswick came to occupy a prominent place in his will.

In the penultimate version of his will, written in November 1962, Coggins stipulated that a trust be created. Four relatives--his much-younger wife, Helen, and three others--would receive fixed-sum, monthly checks until they died. Then the trust would be dissolved and the proceeds given to Keswick if it agreed to build the "Coggins Building."

A little more than a month later--and a little less than a month before he died--Coggins created what would be the final version of his will, adding one more condition to his Keswick bequest: The residence facility had to be for "white" patients. He also added the stipulation that if the conditions were "not acceptable," the money would go to University Hospital.

In court papers, Keswick suggested that because the nursing home was segregated, the addition of "white" merely stated the obvious. "There is no indication in his will or otherwise that Dr. Coggins was a racist," Morkan said.

Maybe the doctor's advanced age was a factor in the changes, he said. "Lots of people perhaps don't have the same grasp over their intellectual powers they might have had previously."

Stiller, the medical center's attorney, agrees that there is no way to know what prompted the amendments. In court filings, the medical center suggested that the changes must be viewed in the context of the last two months of 1962, "a time when, on a daily basis, the media reported desegregation successes in hospitals, nursing homes, places of public accommodation and housing."

In particular, on Nov. 23 four state mental hospitals were ordered to desegregate. Whether other facilities would follow "was still uncertain," the court papers said. By including the "white" proviso and a default gift to the hospital, Coggins might have been responding to events.

"Dr. Coggins didn't want them to have it if they couldn't be in accordance with his way of looking at the world," Stiller said.

Within a month of the doctor's death, Keswick learned about the trust--which started with $2.3 million--and its place in his will. Although officials knew it might be many years before all four relatives died and the trust money became available, the nursing home moved forward with a Coggins Building, even hanging his portrait in the lobby. It shows a serious, elderly man dressed in a white shirt, brown suit and vest and striped tie.

Segregation became illegal in 1964, and Keswick admitted its first black resident in 1967. On Sept. 10, 1998, the last of the four relatives--Helen Coggins--died. But before dispersing a fund that had increased tenfold, the executor of the estate, Mercantile Safe Deposit and Trust Co., sought a court opinion about the "white" stipulation. That led to Kaplan's ruling.

Keswick officials said the nursing home does not need the gift to survive because the Coggins Building has been paid for. But they argued that Coggins clearly intended that Keswick have the money.

His widow lived out her days there, they said, in a desegregated facility. "If this man was a hard-core racist," Morkan said, "it's unlikely his wife would have served on the board after integration."

The two sides, Keswick and the medical center, are willing to share the $29 million, but negotiations to determine the split broke down last week, prompting Keswick to appeal the court ruling.

Whatever happens, Keswick says, the residence facility will still bear the name of Jesse C. Coggins.