Mississippi state Rep. Willie Bailey (D) holds a package of a popular synthetic urine used to circumvent drug testing in February during a hearing in Jackson. (Rogelio V. Solis/AP)

As part of a routine drug test, Adam Randall handed a vial of yellow liquid to a probation officer.

Although it looked like a urine sample from the 31-year-old — who was required to submit to testing after a previous conviction — authorities in Queensbury, N.Y., say it was not. They allege that Randall turned over a synthetic liquid he had sneaked into the probation office via a bottle stuffed into his pants, a substance so in demand that states are now taking steps to ban it: fake pee.

With the nation’s opioid crisis raging, rates of cocaine and methamphetamine abuse soaring and recreational marijuana use becoming legal in nine states and the District, the concern about clean drug tests, too, has increased. While people have long tried to cheat drug exams with an array of creative methods — such as providing other people’s urine, attempting to flush their systems with gallons of water or using herbal remedies — authorities say synthetic urine has become the new go-to trick.

So much so that states are enacting laws to ban the sale of fake urine, which retails for about $17 to $40 in head shops, truck stops and on the Internet, and is easy to purchase. The substance — made from chemicals and, some claim, uric acid — goes by names including “Monkey Whizz” and “UPass.” Authorities say the products give drug users a way to sidestep screening exams administered by police, courts and employers for safety and security.

Laws making it illegal to sell or use synthetic urine or cheat on a drug test are on the books in at least 18 states, according to the National Conference of State Legislatures. Indiana and New Hampshire banned synthetic urine last year. Bills to do so were introduced this year in Missouri and Mississippi.

Mississippi’s bill was dubbed the “Urine Trouble Act,” drawing snickers and groans in the State House. But its sponsors and others said that the jokey name belies a real problem: Truck drivers, people who operate heavy machinery and others can use the synthetic liquid to easily thwart a drug test, potentially creating public risks.

“Our employers are reporting to us a concern that more and more of their employees are using synthetic human urine to cheat on a drug test,” said Dan Gibson, executive director of the Mississippi Association of Self-Insurers, which has lobbied for the bill.

Mississippi state Rep. Willie Bailey (D), speaking at a hearing in Jackson, held a bottle of fake urine that came with instructions suggesting that users could microwave it to achieve body temperature. He said the substance has been a “hot seller” in truck stops statewide.

“They can’t keep it in stock,” he said.

The bill passed the Mississippi House but died in the Senate. Gibson said his members were troubled that the legislation failed; the association plans to lobby for another effort next year.

“Maybe we’ll call it ‘urine trouble again,’ ” Gibson said.

David Powell, executive director of the Indiana Prosecuting Attorneys Council, has heard numerous accounts of people on probation getting caught with fake urine. They often try to slip it into cups while in the bathroom, where they are supposed to be providing urine samples.

“People can basically use it to avoid consequence with their employers and probation officers,” Powell said. “There’s just no other legitimate purpose for it.”

Companies nationwide have reported having trouble finding workers who can pass drug tests. The Federal Reserve reported in a “beige book” survey of economic activity last year that manufacturers have had difficulty hiring experienced or qualified employees, “with some citing candidates’ inability to pass drug tests or to consistently report to work.”

And when people see their livelihood or ability to stay out of jail as being dependent on passing a drug test, it can create a strong motivation to cheat on it.

“If it’s your job or you’re going to probation or you’re going to lose your kids, a lot of those folks will do anything to pass a drug test,” Powell said.

Randall was required to take a drug test as a condition of his probation. Police said the probation officer saw Randall holding a bottle of yellow liquid that he dropped into his underwear. Randall denied doing so, but police said he eventually turned the bottle over to the probation officer. Randall pleaded guilty to charges of tampering with physical evidence, a felony; his lawyer declined to comment on the case.

In some states, laws regarding fake urine have been spurred by tragedy.

Judy Tilton walked into her 21-year-old son’s room in 2015 and found him dead of a fentanyl overdose. Seth was cold to the touch, still sitting upright on his bed, a needle in his arm and a cellphone in his hand. He had been texting his drug dealer.

Overwhelmed with shock and grief, Tilton cleaned the room a few days later and stumbled upon an unopened bottle of synthetic urine, something that she didn’t even know existed.

“It just made me think and go, ‘Who else is using this?’ ” she said. “It could be a bus driver, it could be an aircraft pilot, a trucker driving down the road. They’re endangering everybody.”

Tilton, of New Hampshire, lobbied legislators to ban fake urine. She testified at the State House, showing lawmakers the box that she found in Seth’s room.

The U.S. Supreme Court first upheld the right to test for drugs in the workplace in 1989, and most of those tests now are conducted using urine samples. The federal government is looking at standardizing tests that use hair and saliva.

Barry Sample, director of science and technology for the Employer Solutions business of Quest Diagnostics, suggests that employers should rotate hair, saliva and urine tests to create an element of surprise for applicants and to make the options for possible cheats, such as fake urine, less useful.

But hair testing has been challenged in court, including by a group of black Boston Police officers who claim it is discriminatory because the texture of African American hair makes it more likely to yield false positives.

Most specimens undergo what is known as a five-panel test, during which they are screened for amphetamines, cocaine, marijuana, PCP and opioids.

The Substance Abuse and Mental Health Services Administration added a sixth — ecstasy — to the test administered to safety-sensitive workers. The agency approved testing federal workers for four prescription painkillers — OxyContin, Vicodin, Percocet and Dilaudid — last year, along with tests for heroin metabolites.

But urine testing remains the main method of detecting drugs in the body, and its private nature can be problematic.

“Urine tests are not observed,” Sample said. “It does afford those who want to cheat the opportunity to try to subvert the testing process.”

Alice Crites contributed to this report.