William S. Sessions, a director of the FBI under three presidents, from 1987 to 1993, who challenged racial and gender bias in his agency but struggled to redefine its mission in a time of domestic turmoil, and who was fired after being accused of ethical lapses, died Friday in San Antonio. He was 90.

His daughter Sara Sessions Naughton confirmed the death, at the home of one of Sessions' sons. The elder Sessions had lived in San Antonio as well.

Sessions arrived in Washington as a figure of stern probity, a Republican hailed by Democrats and Republicans as a scrupulously fair federal judge from West Texas. Nominated by President Ronald Reagan, he sailed through Senate confirmation, 90-0, for what was supposed to be a 10-year term at the helm of 10,000 agents, 56 field offices and the traditions of a storied Federal Bureau of Investigation.

But in a tenure crowded with troubles and stumbling responses, Sessions presided for less than six years over an agency that mounted much-criticized deadly sieges at Ruby Ridge, Idaho, and Waco, Texas; tried to enlist American librarians to catch Soviet spies; and was forced to concede that agents in the past had overzealously spied on Americans protesting government policies in Central America.

Sessions was applauded for broadening the FBI ranks to include more black, Hispanic and female agents. Facing complaints and lawsuits alleging bias in an agency that had long been overwhelmingly male and white, he acknowledged serious problems and ordered reforms in its affirmative action programs. He streamlined procedures for bias complaints, reached settlements with black and Hispanic agents, and was credited with hiring and promoting scores of women and members of minority groups.

"The FBI is a proud organization," he told a congressional hearing in 1989. "It has sometimes been difficult for us to recognize that there is the potential for injustice in our own ranks."

Sessions had to face further accusations that FBI agents under his predecessor, William H. Webster, had violated the rights of groups opposed to administration policies in El Salvador. Civil liberties lawyers produced evidence that agents had infiltrated protest groups, photographed peace rallies and compiled dossiers on thousands of dissidents.

At first Sessions defended the surveillance, saying that it had not been politically motivated and that it had been halted after it found no evidence that terrorists had been aided. But after further inquiry he conceded that spying on opposition groups, like the Committee in Solidarity with the People of El Salvador, from 1983-85 had been too broad. He disciplined six FBI supervisors and ordered that the files on dissidents be purged.

In another concession, Sessions in 1988 curtailed a program that encouraged librarians to report people whose reading materials might suggest that they were Soviet spies. After outcries from Congress and library associations, he ordered that the initiative be made strictly voluntary and that it be confined to the New York area.

The first of the sieges under his watch occurred in 1992, when for 11 days the FBI's hostage rescue team surrounded a fugitive white separatist and others holed up in an isolated cabin on Ruby Ridge, near the Canadian border. After a U.S. marshal and the fugitive's wife and son were killed by gunfire, a public furor arose questioning that use of deadly force. Sessions was not directly involved in the episode or accused of any wrongdoing, but the FBI's reputation was tarnished.

His agency again faced heavy criticism in 1993 over another violent standoff. This one began when four agents from the federal Bureau of Alcohol, Tobacco, Firearms and Explosives and six members of a cult called the Branch Davidians were killed in a gun battle at their compound near Waco, Texas. After a 51-day FBI siege, President Bill Clinton and Attorney General Janet Reno, fearing mass suicide, authorized a tear-gas assault on April 19. The compound caught fire. At least 75 people died, including many children.

By then, FBI morale was abysmal and Sessions, a Republican stranded in a Democratic limbo, was under pressure to resign. His critics said he had failed to redefine the FBI's crime-fighting and domestic counterintelligence missions after the collapse of the Soviet Union in 1991 during the administration of President George Bush. Some associates called him disengaged, a director who relished the trappings of high office but not the grind of bureau business.

But most damaging to Sessions was an internal Justice Department report — issued late in the Bush administration but pursued by the Clinton administration — accusing him of ethical violations, including using FBI planes to visit relatives and friends around the country, often taking his wife; using agents to run personal errands; and having a $10,000 fence built around his Washington home at federal expense.

His defenders called the complaints trivial. He denied wrongdoing, insisting that his trips had been for legitimate FBI business and that the fence was necessary for his family's security. For six months, he resisted requests for his resignation.

"It is because I believe in the principle of an independent FBI that I have refused to voluntarily resign," he said.

For Clinton, it was a vexing personnel problem. Sessions's term still had 4 1/2 years to run. Ten-year terms, subject only to presidential cancellation, were begun after J. Edgar Hoover's death in 1972 to insulate directors from politics and limit their service in the wake of Hoover's 48-year reign.

After rejecting a final presidential ultimatum to resign, Sessions was dismissed by Clinton on July 19, 1993.

"We cannot have a leadership vacuum at an agency as important to the United States as the FBI," Clinton said at the time. "It is time that this difficult chapter in the agency's history is brought to a close."

Judge Louis J. Freeh of U.S. District Court in Manhattan, a former FBI agent and federal prosecutor, became director on Sept. 1.

Sessions was the first director to be fired in the FBI's history; the second was James Comey, dismissed almost 24 years later, in May 2017, by President Donald Trump.

William Steele Sessions was born on May 27, 1930, in Fort Smith, Arkansas, to the Rev. Will Sessions Jr. and Edith (Steele) Sessions. His father was a Disciples of Christ minister.

William grew up in Iowa, North Dakota, Nebraska and Kansas, graduating from high school in Kansas City, Kansas, in 1948. He started college but dropped out in 1951, enlisted in the Air Force and rose to captain before being discharged in 1955.

In 1952 he married Alice June Lewis. She died in December. The couple had maintained a home in Washington for many years. In addition to his daughter Sara, he is survived by three sons, William (who goes by his middle name, Lewis), Mark and Pete; nine grandchildren; and five great-grandchildren. Pete Sessions is a former congressman from Texas.

After his military service, Sessions attended Baylor University, earning a bachelor's degree in 1956 and a law degree in 1958. After 10 years practicing law in Waco, he joined the Justice Department in Washington as chief prosecutor of a backlog of cases involving draft evasion and voter fraud.

In 1971, President Richard Nixon named him U.S. attorney for the Western District of Texas. In 1974, President Gerald R. Ford appointed him a federal district judge in El Paso. He later became chief district judge in San Antonio.

In 1982 Sessions drew national attention in presiding over trials that convicted four people in the 1979 assassination of Judge John H. Wood Jr., his predecessor as chief district judge.

After leaving the FBI, Sessions served on Texas commissions on crime, judicial efficiency and homeland security. In 2000, he became a partner in the international law firm Holland & Knight in Washington; he retired in 2016.

During his years at the firm, he often gave pro bono legal counseling in death row and international human rights cases.