Former SAS soldier Andrew Hastie has retained the West Australian seat of Canning for the government amid a swing of at least six per cent to Labor.
With 52 of the 56 polling places returned, Hastie is holding the seat with 54.96 per cent of the two party preferred vote.
The by-election was triggered by the death of veteran MP Don Randall, and had been seen as a vital test for Tony Abbott prior to his dumping as prime minster in favour of Malcolm Turnbull on Monday.
Hastie thanked both men in his victory speech on Saturday night, as well as paying tribute to Randall and the people of Canning.
“After a vigorous interview process you’ve given me a job, I know who my boss is, and I am going to work hard for you and I ask to be judged on my actions over the next few months,” Hastie said on Saturday.
“It’s a huge responsibility and I will work very hard for you.”
Voter dissatisfaction with the government may have been diffused in Canning but it wasn’t forgotten, with Hastie sitting on a 4.95 per cent margin on Sunday morning, down from the 11.8 per cent held by Randall.
Prime Minister Turnbull tweeted his congratulations, while Foreign Minister Julie Bishop said she predicted Hastie would have a long career in parliament.
“He will make a mighty contribution to the life of this country and on behalf of the liberal party we are so glad to have him as a member of the party and as a member of Federal Parliament.”
In conceding defeat Labor’s Matt Keogh described Labor’s showing in Canning as a “great result” that showed thousands had voted Labor for the first time.
"Together today, and over the last four weeks, we have fought a noble fight, we have fought a strong fight," he said.
“We have had front and centre some of the key fights, the key issues, of our movement and our party,” he said, citing protecting penalty rates and job protection measures in the China Free Trade agreement.
The win comes as Prime Minister Turnbull prepares to announce his front bench on Sunday, which is expected to see the elevation of a number of women and new faces in key portfolios.
In perhaps the worst kept secret in Canberra, Social Services Minister Scott Morrison is tipped to become treasurer, while education Minister Christopher Pyne said to be moving to Defence.