DUBLIN — Prime Minister Leo Varadkar of Ireland has narrowly averted the collapse of his government, but he emerged from a political crisis badly weakened on Tuesday, just weeks before a crucial European Union meeting about Brexit and the country’s border with Britain.

Mr. Varadkar’s deputy prime minister, Frances Fitzgerald, resigned on Tuesday over her role in a policing scandal. Her resignation was announced hours before a no-confidence vote was due in Parliament, averting a snap election.

“I believe it is necessary to take this decision to avoid an unwelcome and potentially destabilizing general election at this historically critical time,” Ms. Fitzgerald said in a statement posted on Twitter.

The main opposition party, Fianna Fail, had threatened to withdraw its support of the minority government unless Ms. Fitzgerald quit or was fired. Its leaders have questioned Ms. Fitzgerald’s role in a previous government that they accuse of failing to shield a whistle-blower who exposed police corruption.