SIOUX FALLS, S.D. — South Dakota will get $27.5 million that has been tied up in a long legal dispute between the state and large tobacco companies, Attorney General Marty Jackley said Wednesday.

Jackley’s office said the agreement settles a long dispute over enforcement of a 1998 settlement that requires tobacco companies to compensate 46 states, including South Dakota, for public health costs from smoking-related illnesses. The companies had argued the state wasn’t properly enforcing tobacco-control laws, Jackley said.

Alaska and North Dakota this week announced tobacco settlements for $26 million and $34 million. In South Dakota, Jackley said the settlement money will go to a state fund for education to “help teachers and their students.”

The Education Enhancement Trust Fund currently provides funding for state aid to education and the South Dakota Opportunity Scholarship, according to the Bureau of Finance and Management.

“I’m here today to really announce the conclusion of one lawsuit that’s significant to the state and the beginning of another,” Jackley told reporters at a press conference in which he also said that his office is suing several prescription drug manufacturers for deceptively marketing opioid medications.

The civil complaint dated Wednesday was filed in state court against Purdue Pharma, Endo Health Solutions and Janssen Pharmaceuticals. South Dakota is among more than a dozen states that have filed lawsuits against drugmakers.

The lawsuit alleges the drug companies broke state deceptive trade and Medicaid fraud laws, and created a public nuisance by spreading false information about the risks and benefits of opioid medications. The state is seeking damages, civil penalties and an end to any current “unlawful promotion of opioids.”

Janssen Pharmaceuticals spokesperson Jessica Castles Smith said in a statement that the company’s actions to promote the medications were appropriate and responsible. She said the allegations against the company are “baseless and unsubstantiated.”

Purdue and Endo didn’t immediately return requests for comment from The Associated Press.