'Sorry affair': Rise and fall of chief constable Phil Gormley
Gormley took control of Police Scotland in 2015 - its third chief in five years.
His tenure as Scotland's top police officer, now over, has been described as a "sorry affair" and a "troubled period" by opposition politicians.
Phil Gormley took the reins as chief constable of Police Scotland at the tail-end of 2015, replacing Sir Stephen House.
House had resigned that year amid controversies over the stop-and-search policy, armed policing and the deaths of a couple on the M9, only three years into the job.
It was hoped Gormley, with his wealth of experience, would bring stability and help the force move on from these scandals.
Instead his time at Police Scotland was marred by new controversies, and as allegations of bullying and dishonesty emerged against him, Gormley's leadership turned into a political football.
On Wednesday, Gormley tendered his resignation in the face of five misconduct investigations.
His appointment to the position of Scotland's chief constable arrived off the back of decades of experience in British policing.
Beginning his career in 1985, he became a commander at the Metropolitan Police in 2003, first overseeing firearms and aviation security and then special branch and counter-terrorism.
He was then made chief constable of Norfolk Constabulary in 2010, a position he held for three years before moving to the National Crime Agency to be deputy director general.
Shortly after his appointment as chief constable in Scotland, it emerged that in his time in control of the Met's special branch, Gormley had also overseen a disgraced undercover unit.
Some operatives in the Met's special demonstration squad (SDS) infiltrated activist groups and entered into long-term sexual relationships with women in the groups, one officer even fathering a child as a result.
Gormley denied any knowledge of the activities, which stretched back to long before his command of the unit.
The revelations led to the judge-led Pitchford Inquiry of undercover policing in England and Wales, which is ongoing and has been subject to severe delays.
A similar review of undercover policing in Scotland between 2010 and 2016 found no evidence that officers operated "outwith the parameters of the authorisation".
In July last year, Gormley confirmed that he was under investigation by the Police Investigations and Review Commissioner (Pirc) for gross misconduct.
When a second complaint by a member of Police Scotland's management team sparked a second Pirc investigation, the chief constable announced he would go on special leave.
His deputy, Iain Livingstone, was forced to cancel his retirement plans to effectively assume the role of acting chief constable.
Meanwhile, another complaint led to a third Pirc inquiry in October, followed by a fourth and fifth announced just last month.
In total, seven complaints were made against Gormley. Most relate to alleged bullying but the seventh dealt with a claim of alleged dishonesty at an important internal police meeting.
In the wake of Gormley's resignation, however, Pirc will cease its various investigations into the departing chief constable, passing all information it has gathered on to the Scottish Police Authority (SPA) for a decision.
It recently emerged that in November last year, the SPA's former chairman Andrew Flanagan attempted to have Gormley return to active duty.
The decision was kiboshed by justice secretary Michael Matheson, who said proper procedure had not been followed to reinstate the chief constable.
But Matheson was in turn accused of interfering in the operations of the SPA, which is supposed to be nominally independent of government.
It was then followed by the publication of emails showing Police Investigations and Review Commissioner Kate Frame warning a Scottish Government official not to interfere over the publication of a report criticising the SPA.
Opposition parties framed this as more evidence of ministerial meddling in independent police organisations, calling on Matheson to consider his position.
Gormley may have now left his post as chief constable, but Matheson has rejected any suggestion he should leave his.