William D. Ruckelshaus, a pragmatic and resolute government official who shaped the Environmental Protection Agency in the early 1970s as its first administrator and returned to the agency a decade later to restore its shattered morale after its watchdog powers had been muzzled, died Nov. 27 at his home in Medina, Wash. He was 87.

The death was confirmed by a daughter, Mary Ruckelshaus. She did not cite a specific cause.

In a long career in government and private industry, Mr. Ruckelshaus was widely promoted as “Mr. Clean” as much for his uprightness as for his role with the EPA. He cemented his reputation for unshakable integrity when, in 1973, as President Richard Nixon’s deputy attorney general, he defied a presidential order to fire the special prosecutor investigating the Watergate break-in.

Decades later, as chief executive of Houston-based Browning-Ferris Industries, the second-largest trash-disposal company in the country, he expanded the company’s presence into New York and worked with law enforcement agencies to help break mob control of the city’s trash removal business.

Mr. Ruckelshaus, the scion of a prominent Indianapolis legal family, was a moderate Republican educated at Princeton and Harvard who rose in the Nixon-era Justice Department before guiding the EPA at its birth in 1970.

Hulking, rawboned and bespectacled, Mr. Ruckelshaus shepherded several federal environmental entities into a robust regulatory agency and did as much as anyone to mold the EPA’s mission.

During his three-year tenure, he created policies that forced cities to adopt anti-pollution laws, held automakers to strict emissions standards and banned the harmful pesticide DDT.

J. Patrick Dobel, a University of Washington public affairs professor who has written about Mr. Ruckelshaus’s leadership abilities, said he focused the agency’s mission and drew early media attention to the EPA.

“He got the EPA a lot of public support and built up visibility,” Dobel said.

Around the time Mr. Ruckelshaus stepped down from the EPA in April 1973, the Nixon administration was foundering amid accusations that it had obstructed justice by covering up its involvement in the June 1972 break-in at the Democratic National Committee offices at the Watergate complex in Washington.

Mr. Ruckelshaus, who had no connection to the scandal, was made acting FBI director and then deputy attorney general in an effort by the Nixon administration to rebuild public confidence.

In 1973, Archibald Cox, a Harvard law professor appointed by Attorney General Elliot L. Richardson to investigate the break-in, had requested complete access to Oval Office tape recordings of the time immediately after the break-in. Nixon rebuffed the request and ordered Richardson to fire Cox on Oct. 20, 1973. Richardson refused and resigned.

Shortly afterward, Gen. Alexander Haig, Nixon’s chief of staff, phoned Mr. Ruckelshaus and instructed him to fire Cox.

“Your commander in chief has given you an order,” Haig said.

Mr. Ruckelshaus, who had promised the Senate during confirmation hearings that he would protect Cox, refused to carry out Nixon’s order and then resigned. The duties of the attorney general were transferred to Solicitor General Robert H. Bork, who agreed to fire Cox.

The event became known as the “Saturday Night Massacre” and precipitated the downfall of the Nixon presidency in August 1974.

Of his role, Mr. Ruckelshaus later said, “It was not a heroic act.”

After promising Cox the freedom to investigate the Watergate scandal, he said, “What I was requested to do was violate that promise.” The decision to quit, he said, was “very easy.”

Mr. Ruckelshaus was serving as vice president of legal affairs for Washington state-based timber giant Weyerhaeuser when President Ronald Reagan asked him to return as EPA administrator in 1983.

An earlier Reagan appointee, Colorado conservative Anne Gorsuch Burford (the mother of Supreme Court Justice Neil M. Gorsuch), had depleted the agency by asking Congress to cut the EPA budget, eliminating jobs, halting enforcement activities and spinning off many regulatory functions to the states.

Some of her senior staffers kept a list of career appointees deemed disloyal to Reagan and let the entire staff know of the list. During Burford’s tenure, Congress suspected the EPA was misspending hazardous waste cleanup funds and ordered that financial documents be turned over. Burford refused. She and 12 senior EPA officials were fired or resigned.

Reagan appointed Mr. Ruckelshaus to revive the demoralized agency. On his first on the job, agency officials unfurled a banner, “How do you spell relief? R-U-C-K-E-L-S-H-A-U-S,” a reference to a popular Rolaids commercial.

On his second day, he fired four people to make room for his own management team. Mr. Ruckelshaus set out to improve the agency’s image and, during his two years leading the EPA, received Reagan’s support and opened relations with Congress.

In 2008, Time magazine rated Mr. Ruckelshaus among the best Cabinet secretaries in U.S. history. (The EPA was given Cabinet-level status in 1990.)

William Doyle Ruckelshaus was born in Indianapolis on July 24, 1932. His family had long been active in the state Republican Party. His father had once considered running for the Senate but declined, believing a Catholic would never win in Indiana.

Mr. Ruckelshaus attended Princeton University, where he was a lackluster student. To discipline his inattentive son, his father, who was chairman of the local draft board, got his son drafted. He returned to Princeton after two years in the Army and graduated cum laude in 1957.

Mr. Ruckelshaus received a law degree from Harvard in 1960 and then joined his family’s Indianapolis law firm. Later that year, he was appointed state deputy attorney general and worked as counsel with the Indiana Board of Health, where he took legal action against companies polluting state waterways. It was his first foray into environmental policy and contributed to his later EPA appointment.

His first wife, Harvard Law School classmate Ellen Urban, died in childbirth in 1961. The next year he married Jill Strickland, who later served on the U.S. Civil Rights Commission. In addition to his wife, of Medina, survivors include twin daughters from his first marriage, Mary Ruckelshaus of Seattle and Cathy Ruckelshaus of Chappaqua, N.Y.; and three children from his second marriage, Jenny Ruckelshaus of Sutter Creek, Calif., and William J. Ruckelshaus and Robin Ruckelshaus Kellogg, both of Seattle; a sister; and 12 grandchildren.

Mr. Ruckelshaus was elected to the Indiana House of Representatives in 1966 and became the first freshman legislator to serve as majority leader. In 1968, he mounted an unsuccessful challenge against incumbent Sen. Birch Bayh (D).

After the election, Mr. Ruckelshaus was asked by the Nixon White House to become head of the Justice Department’s civil division. He quickly impressed Nixon and Attorney General John Mitchell by deftly handling student protests against the Vietnam War’s expansion into Cambodia.

Mr. Ruckelshaus persuaded the attorney general and the president to allow the demonstrators to protest near the White House grounds, resolving the tensions without violence. Nixon later asked him to tour college campuses to communicate the administration’s line with students.

By 1970, Congress had passed several environmental bills, including the Clean Air Act. The federal government, however, lacked an individual agency to enforce the laws. Regulation was spread across 15 separate agencies, which blunted the government’s influence on environmental policy.

Nixon created the EPA by executive order and appointed Mr. Ruckelshaus as its first administrator. Less than two weeks into his tenure, he ordered the mayors of Atlanta, Cleveland and Detroit to develop plans to correct water-quality violations or face the prospect of legal action. Within months, he ordered cities to enact clean-air standards by 1975, and factory owners were required to provide detailed reports on materials dumped into waterways.

“We did come out pretty fast,” Mr. Ruckelshaus told USA Today in June 2010. “There were a lot of handy targets around. And I felt we needed to show the public that we were serious.”

The 1970 Clean Air Act also included strict auto emissions guidelines that were to be met by 1975. The law required that automakers reduce carbon monoxide emissions by 90 percent from the levels of 1970-model cars. As a result, the emissions-reducing catalytic converter became standard on American cars.

One of Mr. Ruckelshaus’s most significant moves at the EPA was to ban the harmful pesticide DDT, University of Arizona professor J.E. “Ed” de Steiguer said in an interview.

The pesticide became a target of the environmental movement after biologist Rachel Carson called it the “elixir of death” in her influential 1962 book “Silent Spring.” Because DDT was virtually nondegradable, it was transferred through the food chain. It was particularly devastating to birds and contributed to the near extinction of the bald eagle, the national symbol of the United States. The bald eagle eventually rebounded and was taken off the endangered-species list in 2007.

In 1988, Mr. Ruckelshaus became chief executive of Browning-Ferris Industries, which had a spotty environmental and legal record. After a headline in the publication Industry Week — “ ‘Mr. Clean’ turns ‘Garbage Man’ ” — Mr. Ruckelshaus replied in a letter to the editor: “You did your usual thorough and fair job. My only complaint is that I did not come out as a combination of Mahatma Gandhi, Winston Churchill and Clint Eastwood.”

Under his administration, BFI expanded into New York City. The company’s trucks and trash collectors were often escorted by guards, but eventually BFI was able to break organized crime’s grip on trash removal.

“They’d steal the containers if we had containers out,” Mr. Ruckelshaus told “Dateline NBC” in 1998. “They even stole a truck one time, and just general harassment — the kind of thing that actually doesn’t go on in other marketplaces in our business.”

A longtime Seattle resident, Mr. Ruckelshaus served from 2007 to 2010 as the first head of the Puget Sound Partnership, an environmental agency in Washington state. In 2015, President Barack Obama awarded him the Presidential Medal of Freedom, the nation’s highest civilian honor.