F. Lee Bailey, one of the nation’s most storied criminal trial lawyers and a tenacious defender of O.J. Simpson, Patty Hearst and a host of other famous and infamous clients in a tumultuous career punctuated by his own collisions with the law and his eventual disbarment, died June 3 at a hospice center in the Atlanta area. He was 87.

His son Bendrix Bailey confirmed the death but did not cite a specific cause.

Mr. Bailey was celebrated in some corners and scorned in others as he represented deeply unpopular suspects ranging from mutilation murderers and international drug lords to get-rich-quick-scheme artists. In the courtroom, he fascinated the public with his cool, pointed oratory and prodigious memory, as well as his relentlessness.

He avidly sought the limelight — even appearing in a Smirnoff vodka ad — and in his give-no-quarter advocacy for his clients, he rarely acknowledged defeat. Steven Brill, founder of Court TV and the American Lawyer magazine, once called him “an enduring legal figure in the sense that he’s been willing, and in fact relished, taking on clients that were the demons of society.”

A former private investigator, Mr. Bailey was regarded as a master of pretrial preparation — meeting with key witnesses, collecting pictures and documents and visiting locations relevant to the crime. The purpose, he said, was to “stuff my head with enough facts for when the action starts.”

Mr. Bailey could question witnesses for hours without notes and was likened by colleagues to such superstar 20th-century courtroom advocates as Clarence Darrow, Edward Bennett Williams and Percy Foreman, who defended James Earl Ray following the assassination of the Rev. Martin Luther King Jr.

The jury was not the only audience Mr. Bailey played to. He championed his clients in an almost constant barrage of commentary to reporters and appearances on “The Tonight Show,” “The Mike Douglas Show” and other television talk programs.

“Massachusetts just burned another witch,” he growled to reporters after a jury in 1967 rejected an insanity plea on behalf of sexual assault defendant Albert DeSalvo. DeSalvo separately had confessed to Mr. Bailey to being the widely feared “Boston Strangler” sought in the killing of 13 women in the early 1960s.

Mr. Bailey adroitly excluded the confession from court, then unsuccessfully challenged what he contended was the state’s antiquated definition of criminal insanity in DeSalvo’s unrelated sexual assault case.

DeSalvo was sentenced to a 10-years-plus-life term. Police, lacking any clues beyond the confession, never charged him in the Boston Strangler case. DeSalvo was killed in prison in 1973 by another inmate.

For all his courtroom wizardry, Mr. Bailey spent much of his life consumed with personal legal troubles. He was jailed, found in contempt of court and criminally charged in a range of legal entanglements.

His verbal antics got him barred from practice for one year in New Jersey after he suggested that prosecutors bribed witnesses in a murder case. In 1970, a Massachusetts judge censured him for “his philosophy of extreme egocentricity.”

He was acquitted of a drunken-driving charge in San Francisco in 1982. The lengthy trial, involving seven police witnesses, provoked Mr. Bailey to write “How to Protect Yourself Against Cops in California and Other Strange Places,” a 90-page handbook on guarding against police abuses.

In 1973, he was indicted in Florida on investor fraud charges along with his client, cosmetics super-salesman Glenn Turner. Mr. Bailey was accused of making speeches that endorsed investments in Turner’s franchises. The trial ended in a hung jury. The case, however, had pushed Mr. Bailey to the financial brink, and his business fell sharply. It took him a few years to rebound.

In 1996, he was jailed for 43 days for contempt of court stemming from accusations that he misused as legal fees millions of dollars in stock owned by convicted international drug trafficker Claude Duboc. Later, he was disbarred in Florida and Massachusetts in the matter.

In 2016, at age 83, he filed for bankruptcy in an unusual attempt to set aside a federal tax debt of almost $5.2 million stemming largely from the Duboc case. The Internal Revenue Service contended he failed to report a portion of Duboc’s stock as income.

When not attending to his own woes, he maintained a frantic schedule of trials and other court appearances for clients, often piloting his own Lear jet across the country for appointments.

With an energy that staggered his colleagues, he kept a busy schedule of high-priced speeches and lectures and authored or co-authored more than a dozen how-to manuals for lawyers in addition to a novel titled “Secrets” (1978). He also oversaw a range of business ventures, including a boat- and plane-renovation company, a publishing house for children’s books and a computer service for lawyers.

While his legal victories were numerous, the thickset, conservatively dressed Mr. Bailey (except for his signature cowboy boots) saw his fortunes repeatedly rise and fall.

As early as 1966, he won a precedent-setting U.S. Supreme Court reversal of famed Ohio osteopath Samuel H. Sheppard’s conviction in the murder of his wife. Mr. Bailey’s argument, unheard of at the time, convinced the high court that Sheppard was denied a fair trial because the trial judge had failed to shield the jury adequately from massive prejudicial publicity.

At retrial, Sheppard was acquitted. The TV series “The Fugitive” and a 1993 movie of the same name were loosely based on the Sheppard story.

In 1976, Mr. Bailey lost an equally celebrated case in which a San Francisco jury rejected his claim that Patty Hearst, the newspaper fortune heiress, after being kidnapped by radical Symbionese Liberation Army members, was “brainwashed” into participating in an armed robbery of a local bank.

She was convicted as charged and sentenced to seven years but had the time commuted to two years by President Jimmy Carter in 1979. She was fully pardoned by President Bill Clinton in 2001.

Mr. Bailey’s self-claimed crowning success was his pivotal role in winning an acquittal in the racially charged murder trial of O.J. Simpson. The former actor and National Football League star, who is African American, was accused of murdering his ex-wife, Nicole Brown Simpson, who was White, and her friend, Ronald Goldman, in 1994.

In the widely televised Simpson murder trial before a predominantly Black jury, Mr. Bailey — one of several high-octane lawyers on Simpson’s “dream team” — bore in on Los Angeles police detective Mark Fuhrman, suggesting that he had planted a bloody glove at the crime scene. He also questioned Fuhrman about using the n-word in reference to African Americans.

“Have you used that word in the past 10 years?” he asked Fuhrman.

“Not that I recall, no.”

Mr. Bailey continued questioning the detective in a thrust-and-parry manner, then introduced a 1985 audiotape in which Fuhrman freely used the slur. He also produced four witnesses saying Fuhrman had used the word, although many of his colleagues past and present told reporters he was not the bigot he was being portrayed as.

Fuhrman was later charged with perjury, pleaded no contest and was sentenced to three years’ probation and a $200 fine.

After questioning Fuhrman, Mr. Bailey reveled in what appeared to be the success of his examination. “I’m not Perry Mason; nobody is,” he told Time magazine, referring to the fictional lawyer long played on TV by Raymond Burr. “Other lawyers whom I respect told me that given what I had to work with, it was good. Norman Mailer called me and said it was flawless. So I feel good.”

Francis Lee Bailey Jr. was born June 10, 1933, in Waltham, Mass., a Boston suburb. His parents, Francis Sr., a newspaper ad salesman, and the former Grace Mitchell, a children’s nursery operator, divorced when he was 10.

Son and mother clashed, leading her to enroll him in a New Hampshire boarding school called Cardigan Mountain. Even in those early years, he showed an independent streak, pursuing activities including oratory, carpentry and an unusually rough version of ice hockey.

“Lee is far too much a law unto himself,” Cardigan’s headmaster fretted, according to a Time magazine cover story on Mr. Bailey in 1976.

After graduating in 1950 from Kimball Union Academy in New Hampshire, he entered Harvard University on a scholarship but dropped out after two years. “I was thoroughly incapable of academic dedication,” he wrote in his 1972 bestseller, “The Defense Never Rests.”

He joined the Navy’s flight-training program, then transferred to the Marines and became a jet fighter pilot. He also volunteered for a three-member legal team at Cherry Point Marine Corps Air Station in North Carolina and soon became immersed in the station’s legal affairs, an experience that seemed a seminal factor in his decision to make a career of the law.

Discharged from the Marines in 1956, he returned briefly to Harvard but applied to Boston University law school where he was accepted without completing undergraduate school. He obtained his law degree in 1960 at the top of his class.

Even before he finished law school, he had founded a private detective agency and became an expert in the relatively new field of polygraphy, or lie-detector testing, a skill that would help trigger his meteoric rise.

His breakthrough came in late 1960 in the “Torso Murder” case, in which Lowell, Mass., auto mechanic George Edgerly had been charged with killing his wife and dumping her dismembered remains in a river.

Edgerly had failed a lie-detector test, and Mr. Bailey was brought in to challenge the prosecution’s polygrapher. When the principal defense lawyer collapsed from a heart attack, Mr. Bailey took over the case and swiftly won an acquittal.

“This is a case of circumstantial evidence,” Mr. Bailey told jurors. “Nobody saw Edgerly murder his wife and no one so testified. Circumstantial evidence is like a chain and no chain is stronger than its weakest link.”

Word of his skill, knowledge and aggressive trial preparation quickly spread. Within a year, at age 28, he took on the Sheppard case in Ohio, and his reputation as a criminal litigator was assured.

Mr. Bailey’s marriages to Florence Gott, Froma Portnoy and Lynda Hart ended in divorce. His fourth wife, Patricia Shiers, died in 1999. Survivors include two sons from his first marriage, Bendrix and Bryan; a son from his second marriage, Scott; a sister; and five grandchildren.

Among his headline-grabbing successes was the acquittal in 1971 of Army Capt. Ernest L. Medina in the My Lai hamlet massacre in South Vietnam in 1968. Medina was court-martialed on charges of willfully allowing men in his unit to slaughter more than 300 noncombatant villagers.

Mr. Bailey contended that Medina did not learn what was happening until it was too late and that his men acted on their own volition. “If you are 90 percent sure that he is guilty, then you must acquit,” he told the panel of court-martial officers in the closely argued case. “You have no choice, for that’s what reasonable doubt means.”

Medina was found not guilty and subsequently worked in a helicopter manufacturing company owned by Mr. Bailey.

In his later years, Mr. Bailey moved to Yarmouth, Maine, sharing a home with Debbie Elliott, a salon operator. He sought to continue his law practice but was denied admission to the state bar.

He lacks “clear and convincing evidence that he possesses the requisite honesty and integrity,” the Maine Board of Bar Examiners wrote in a 5-to-4 decision in 2013 in a matter stemming from the Duboc case. The next year, the Maine Supreme Judicial Court upheld that decision.

In continuing to press the matter into his 80s — hoping to recapture his license and reclaim his reputation — he proved true his long-held view of the law and his place in it.

“In litigation someone always loses, but they don’t always stay the loser,” he once said. “Those who give up, however, always lose. I’ll fight as long as I have anything to fight with.”