OTTAWA  First Maxime Bernier lost his girlfriend. Then he lost his job as Canada’s minister of foreign affairs.

Mr. Bernier’s political and personal setbacks are directly related. His former romantic interest, Julie Couillard, was linked to Quebec’s motorcycle gangs, which have long tried to infiltrate politics and the justice systems. On Monday night, Mr. Bernier resigned shortly before Ms. Couillard disclosed in a heavily promoted television interview that he had left confidential government documents in her suburban Montreal apartment.

Although Prime Minister Stephen Harper cited only that bit of carelessness as the reason for accepting Mr. Bernier’s resignation, the minister’s departure was widely viewed in Canada as a response to the political fallout from the relationship and to Mr. Bernier’s tendency to make diplomatic blunders.

Biker gangs in Mr. Bernier’s home province of Quebec have, among other things, killed prison guards and shot one prominent crime journalist.