KUALA LUMPUR, Malaysia — The conspirators were confident. They planned to confront Malaysia’s prime minister, Najib Razak, at a cabinet meeting and demand his resignation. Prosecutors had collected evidence that Mr. Najib had deposited millions of dollars of public money into his personal bank account. Attorney General Abdul Gani Patail was ready to file criminal charges, according to Najib advisers and opposition leaders.

Mr. Najib had a reputation as a gentleman who was slow to act and never fired anyone. But when word of the plot reached him last July, he moved quickly. He dismissed both Deputy Prime Minister Muhyiddin Yassin, the man who would have taken his job, and the attorney general. And he blocked further inquiries into the allegations against him.

“They took it for granted that he was a sitting duck,” said Tony Pua, an opposition member of Parliament. “He turned the tables on them.”