LOS ANGELES (Reuters) - “Magnum, P.I.” star Tom Selleck has agreed to pay the nearly $22,000 bill of a private investigator hired by a California agency in a probe that revealed truckloads of water were being illegally diverted to the actor’s ranch during an ongoing drought, officials said.

Actor Tom Selleck talks about his show 'Blue Bloods' during the CBS, Showtime and the CW Television Critics Association press tour in Beverly Hills, California, July 28, 2010. REUTERS/Lucy Nicholson

Officials from the Calleguas Municipal Water District filed a legal complaint against Selleck on July 6 which said a hydrant in their district was tapped to supply his ranch, which is located in a nearby jurisdiction.

A legal settlement between Selleck and the Calleguas district, which was formally approved on Wednesday by directors of the agency, will prevent Selleck from drawing water from the district for use on his ranch in the Hidden Valley area northwest of Los Angeles.

Selleck, who is most famous for playing a Hawaii private investigator in 1980s television show “Magnum, P.I.,” has agreed to pay the district’s nearly $22,000 bill to hire a private investigator, officials said.

The district said that several times from 2013 to 2015 a water-tender truck filled from a hydrant within the Calleguas district and delivered that water to Selleck’s ranch.

The dispute came to light as California endures a devastating four-year drought that has led to mandatory water cutbacks on cities and towns.

“Mr. Selleck previously paid for all the water that he utilized, which the Calleguas Municipal Water District acknowledged had not been stolen,” said Selleck’s attorney, Marty Singer, in a statement.

The metered hydrant was in Thousand Oaks, which is part of the Calleguas water district and was installed for use at a construction site, said the city’s public works director, Jay Spurgin.

A construction company paid for the water, but city officials do not know whether some was diverted out of the district, Spurgin said.

It was unclear if Selleck might have paid the construction company for use of the water, but Calleguas water district general manager Susan Mulligan said in a statement that was irrelevant.

“No one has a legal right to district water by simply paying a rate to another water user based on the volume of water questionably obtained,” Mulligan said.

Eric Bergh, manager of resources for the Calleguas water district, said in an email that Selleck could not have fully paid for the water because, since he is not a resident of the district, he avoided tax assessments and fees.