TORONTO — They were college friends, canoeing pals and debating team buddies who were in one another’s wedding parties.

Together, they fashioned a campaign that catapulted them into Canada’s top office — Justin Trudeau as the country’s optimistic prime minister and his best friend Gerald Butts as his adviser, strategist and political slugger.

Now they are caught in political turmoil over accusations that the Trudeau government improperly tried to influence a criminal prosecution. The controversy could threaten Mr. Trudeau’s job and destroy the legacy they spent years carefully building.

On Wednesday, Mr. Butts — who abruptly resigned just as the problems were beginning to compound and declined to be interviewed for this article — will testify before the Parliament’s justice committee.