An Oklahoma judge on Monday ruled against Johnson & Johnson in the state's opioid suit, forcing the company to pay $572 million in the first ruling in the U.S. holding a drugmaker accountable for helping fuel the epidemic.

Calling the opioid crisis an "imminent danger and menace," District Judge Thad Balkman said, "the state met its burden that the defendants Janssen and Johnson & Johnson's misleading marketing and promotion of opioids created a nuisance as defined by [the law]," including a finding that those actions compromised the health and safety of thousands of Oklahomans.

"Specifically, defendants caused an opioid crisis that's evidenced by increased rates of addiction, overdose deaths and neonatal abstinence syndrome," he added.

The ruling, which J&J intends to appeal, says that the company and subsidiary Janssen repeatedly downplayed the risks of addiction to opioids, training sales representatives to tell doctors the risk was 2.6% or less if the drugs were prescribed by a doctor. Physicians who prescribed a high amount of opioids were targeted as "key customers."

The $572 million judgment against J&J covers one year of costs under the state's plan to combat the crisis, even though the attorney general's office presented several witnesses who said it would take at least 20 years to carry out. "The state did not present sufficient evidence of the amount of time and costs necessary, beyond year one, to abate the opioid crisis," the ruling says.

The fine was significantly less than the penalties sought by Oklahoma, sending J&J's stock up by about 2% in post-market trading after the verdict was read. Investors were expecting J&J to be fined between $500 million and $5 billion, according to Evercore ISI analyst Elizabeth Anderson.

J&J said the decision in the case is "flawed" and that the state "failed to present evidence that the company's products or actions caused a public nuisance in Oklahoma."

"Janssen did not cause the opioid crisis in Oklahoma, and neither the facts nor the law support this outcome," Johnson & Johnson general counsel Michael Ullmann said in a statement. "We recognize the opioid crisis is a tremendously complex public health issue and we have deep sympathy for everyone affected. We are working with partners to find ways to help those in need."

Shares of drugmakers Mallinckrodt, Teva Pharmaceutical and Endo International also rose on the news in after-hours trading.