The Republic of Ireland's Foreign Affairs Minister Simon Coveney won a confidence motion on Wednesday as the Dáil (Irish parliament) returned from its summer recess.
The motion was in relation to controversial plans to appoint a UN special envoy.
In July, it was announced that Katherine Zappone, a former government minister, would take on the role.
However, the following month she withdrew amid accusations by opposition parties of cronyism.
Sinn Féin tabled a motion of no confidence in Mr Coveney over the appointment but the government countered this with a motion of confidence, which was debated and voted on by TDs (members of parliament) on Wednesday.
Who is Katherine Zappone?
Born in the United States, Ms Zappone is a former TD and Irish senator.
She has been a long-time advocate for LGBT+ rights and was an active campaigner during Ireland's referendum on marriage equality.
In 2016, under the Fine Gael government, she was appointed to the role of minister for children and youth affairs and lost her seat as a TD in the country's 2020 general election.
What is the controversy about?
On 27 July 2021, Simon Coveney, a Fine Gael member of the coalition government, informed the cabinet that Ms Zappone would become the new "Special Envoy to the UN for Freedom of Opinion and Expression".
It was reported the role would carry a €15,000 salary (£12,800) and require about 60 days work a year.
After cabinet, it transpired that neither Fianna Fáil nor Green Party members of the coalition cabinet knew about the proposed appointment.
The job had not been advertised and was not open to competition, despite being taxpayer funded.
There was speculation that the news led to internal divisions between the government partners, however, Taoiseach Micheál Martin, of Fianna Fáil, did not block it.
He went on to describe the way it was revealed at cabinet as an "oversight" and suggested people "move on now" in the face of criticism by opposition parties.
But they didn't move on?
No. Attention then shifted to revelations that Ms Zappone had hosted an outdoor function at Dublin's Merrion Hotel on 21 July, days before the cabinet meeting, which was attended by Tánaiste (deputy prime minister) Leo Varadkar, the leader of Fine Gael.
The pair discussed the appointment at the event, but Mr Varadkar later said he had only learned about it through text exchanges the previous week.
In the messages, made public by Mr Varadkar on 1 September, Ms Zappone had asked him on 16 July if he had "heard anything" about the role from Mr Coveney.
Mr Varadkar replied "nope" and later texted Mr Coveney on 19 July if he knew "anything about her becoming our LGBT envoy".
Mr Coveney responded that Ms Zappone was to finalise a 12-month contract on 21 July and was "very happy". Mr Coveney told Mr Varadkar in the text message that he planned to take a memo to government the following week.
Criticism of Mr Coveney's role intensified, however, when he later said that he had deleted text messages about the appointment.
He said he regularly changed his phone and had deleted messages with other government ministers as he was "prudent" and had previously "been hacked".
What else did Simon Coveney have to say?
Mr Coveney denied that he had been lobbied to give Ms Zappone the role and said he thought she was "very suitable" for an area where there was a "worthwhile job to be done".
"I can see why many people would see it as lobbying but I didn't see it as that," he told a Dáil (Irish parliament) committee meeting on 7 September.
The minister did concede that he "made a mistake" and apologised to the taoiseach for not informing him prior to the cabinet meeting.
Mr Coveney also denied claims that Ms Zappone had been offered a UN role from as early as March.
He also rejected an accusation that he had breached freedom of information legislation by deleting text messages.
However, Mr Coveney apologised to the committee for needing to hold a second evidence session with him due to his "sloppiness" over explaining the circumstances behind the row.
On Tuesday, Mr Coveney told a party conference that he was "embarrassed" that the appointment had led to a "fiasco".
"It's not been my finest month in politics," he said.
What did the opposition say?
News of the initial appointment was seized upon by the opposition, in particular Sinn Féin, which accused those involved of displaying cronyism.
Its TD, John Brady, accused the minister of having "misled" the committee "on a number of grounds".
On 8 September, Sinn Féin President Mary Lou McDonald called for Mr Coveney to be sacked and raised the prospect of a vote of no confidence.
She branded his actions as not being "of the standard expected of a minister".
How did Katherine Zappone respond to the fallout?
On 4 August, Ms Zappone explained that she would not take on the role, but had been "honoured" to have been considered for it.
She continued: "It is clear that criticism of the appointment process has impacted the legitimacy of the role itself.
"It is my conviction that a special envoy role can only be of real value to Ireland and to the global community if the appointment is acceptable to all parties.
"For this reason, I have decided not to accept this appointment and I have communicated my decision to the minister for foreign affairs," she added.
How did the vote go?
The government won its motion of confidence in Mr Coveney, 92 votes to 59, on Wednesday evening.
Sinn Féin president Mary Lou McDonald said Mr Coveney tried to "make up a job for a friend" and "when caught red handed, he went about covering his tracks".
Mr Coveney told the Dáil he regretted the "preventable controversy" over the appointment of Ms Zappone.
Mr Martin said Mr Coveney's conduct was wrong but to remove him would be disproportionate.
The tánaiste said without Mr Coveney there would be no government in Northern Ireland, and "Michelle O'Neill (Sinn Féin's deputy leader) would not be the deputy first minister today".
Earlier, the taoiseach warned Fianna Fáil TDs they would face a six-month suspension from the parliamentary party if they voted against or abstained on a confidence motion.
Fianna Fáil TD Marc MacSharry resigned as a result.