Ardern put forward her name for the Labour nomination for the Mount Albert by-election to be held in February 2017 following the resignation of David Shearer on 8 December 2016. When nominations for the Labour Party closed on 12 January 2017, Ardern was the only nominee and was selected unopposed.
On 21 January, Ardern participated in the 2017 Women's March, a worldwide protest in opposition to Donald Trump, the newly inaugurated president of the United States. She was confirmed as Labour's candidate at a meeting on 22 January. Ardern won a landslide victory, gaining 77 per cent of votes cast in the preliminary results.
Following her win in the by-election, Ardern was unanimously elected as deputy leader of the Labour Party on 7 March 2017, following the resignation of Annette King who was intending to retire at the next election. Ardern's vacant list seat was taken by Raymond Huo.
On 19 October 2017, New Zealand First leader Winston Peters agreed to form a coalition with Labour, making Ardern the next prime minister. This coalition receives confidence and supply from the Green Party. Ardern named Peters as Deputy Prime Minister and Minister of Foreign Affairs. She also gave New Zealand First five posts in her government, with Peters and three other ministers serving in Cabinet.