A corrupt Mexican state prosecutor known as “el Diablo” was sentenced to 20 years in federal prison Thursday for taking hefty payoffs to help a violent Mexican drug cartel knock off the competition and peddle drugs into the US.

Edgar Veyta, 48, used his authority as an attorney general in the state of Nayarit to help the notorious H-2 cartel traffic heroin, cocaine and other drugs into the US for at least five years, federal prosecutors in Brooklyn said.

“When Joaquin ‘El Chapo’ Guzmán was sentenced to life imprisonment, we warned that there were more days of reckoning to come. The sentence imposed on this corrupt Mexican government official makes this just such a day,” said US Attorney Richard Donoghue in a statement.

“Neither Mexican cartel leaders nor corrupt officials who assist them should sleep well tonight. We are coming for you.”

Veyta pulled strings to get charges against cartel members dropped, and ordered Mexican law enforcement to go after rival drug traffickers — even using cops to help H-2 carry out murders, federal prosecutors said.

In 2015, the then-attorney general helped cover up the cartel’s hit on a rival drug gang member.

Veyta was arrested in 2017 after a federal grand jury indicted him on conspiracy and trafficking charges. He was hauled to New York in April and jailed at the Metropolitan Correction Center — the same jail that held El Chapo.

The Mexican drug kingpin was hit with a life sentence earlier this year after also being tried in Brooklyn federal court.

Federal agents began cracking down on H-2 in 2013 and gunned down the cartel’s leader, Juan Francisco Patron Sanchez, in 2017, just one month before Veyta was indicted.

Veyta pleaded guilty in January and was sentenced Thursday.

In addition to the 20-year sentence he was ordered to forfeit $1 million.