SÃO PAULO, Brazil — Call it the ultimate mike drop.

Just days before his four-year term ends, Brazil’s attorney general, Rodrigo Janot, filed criminal charges accusing two former presidents of running the state like a criminal enterprise. With these charges, taken together with the corruption charges he has pursued against the current president, Michel Temer, Mr. Janot appears keen to leave his post having condemned the entire political establishment that has run the country over the past 15 years.

On Tuesday, in a surprise move, Mr. Janot, Brazil’s top prosecutor, accused former President Luiz Inácio Lula da Silva; his handpicked successor, Dilma Rousseff; and six other Workers’ Party stalwarts of running a huge kickback scheme during their nearly 14 years in power.

Ms. Rousseff, who was impeached and ousted in August 2016 for breaking budgetary laws, has maintained that she was a fundamentally honest public servant who fell victim to a legislative “coup” by conniving rivals, including Mr. Temer. Mr. Janot is challenging that narrative, asserting that his office has enough evidence to demonstrate that she was more than a bystander in a multibillion pay-to-play scheme that drained the government’s treasury while enriching scores of businessmen and politicians.

In June, Mr. Janot took a swing at Mr. Temer, accusing him of condoning payment of a bribe to keep an imprisoned politician from cooperating with prosecutors.