Prime minister Justin Trudeau’s top adviser has resigned while denying allegations that he pressured Canada’s former attorney general to avoid prosecuting a major Canadian engineering company.

Principal secretary Gerald Butts has been Trudeau’s closest adviser and best friend since university, and his resignation over the widening scandal was a significant blow to the prime minister, who is facing an election this year.

Butts issued a statement denying that anyone in Trudeau’s office pressured then attorney general Jody Wilson-Raybould.

“I categorically deny the accusation that I or anyone else in his office pressured Ms Wilson-Raybould,” Butts said.

“But the fact is that this accusation exists. It cannot and should not take one moment away from the vital work the prime minister and his office is doing for all Canadians.”

The Globe and Mail newspaper reported this month that Trudeau or his staff pressured Wilson-Raybould to try to avoid a criminal prosecution of Montreal-based SNC-Lavalin over allegations of corruption involving government contracts in Libya.

Critics say that would be improper political meddling in a legal case.

Nelson Wiseman, a political science professor at the University of Toronto, said the Butts resignation is “big and simply feeds the story that Butts pressured Wilson-Raybould.”

“As principal secretary to the prime minister, Butts was Justin Trudeau’s eyes, ears, nose and, most importantly, mouth,” Wiseman said. “Trudeau has leaned on Butts more than anyone. They go back to being undergraduates at McGill (University) at the same time.”

Wilson-Raybould resigned from the Cabinet as veterans affairs minister last week but gave no reasons. She had been demoted from justice minister last month and was furious, releasing a 2,000-word statement after that.

The Globe and Mail’s report this month said Trudeau’s office pressured her to instruct the director of public prosecutions — as allowed by law — to negotiate a remediation agreement with SNC-Lavalin.

The agreement would have allowed the company to pay reparations but avoid a criminal trial on charges of corruption and bribery.

If convicted criminally, the company would be banned from receiving any federal government business for a decade. SNC-Lavalin is a major employer in Quebec, with about 3,400 employees in the province, 9,000 employees in Canada and more than 50,000 worldwide.

Wiseman said Trudeau’s office mishandled the case.

“Where I think the government fell short is that as soon as Wilson-Raybould resigned they should have offered the very sound economic and business rationale for using remediation in the SNC-Lavalin case,” Wiseman said.

“As it is, they bad-mouthed Wilson-Raybould and denied pressure was applied.”

Wilson-Raybould has hired a former Supreme Court justice to advise her on what she can say publicly about the matter. Opposition leaders called on Trudeau to waive lawyer-client privilege to allow Wilson-Raybould to tell her side of the story.

Trudeau issued a brief statement about Butts, who is credited with helping Trudeau’s Liberals rise from Canada’s third largest party to win power in the 2015 election.

“Gerald Butts served his government — and our country — with integrity, sage advice and devotion. I want to thank him for his service and continued friendship,” Trudeau tweeted.

Andrew Scheer, leader of the opposition Conservative Party, said the latest resignation shows a government in “chaos as Trudeau desperately tries to cover up this scandal”.

“Canadians are rightly concerned about the allegations of political interference in a criminal prosecution. Trudeau needs to stop hiding behind other people and come clean,” Scheer tweeted.