Liberal Andrew Hastie, a former officer in Australia’s Special Air Service, has been elected by the people of Canning to replace former member Don Randall, who died in July.
Mr Hastie claimed victory about 8.15pm when Labor's Matt Keogh called to concede defeat.
The count had Mr Hastie at 55.9 per cent of the two party preferred vote and 47.0 per cent of the primary vote.
The swing against the Liberal party was 5.9 per cent, less than predicted in recent polling.
A former officer in the Australian Special Air Service, Mr Hastie was preselected by local Liberals as their candidate in August.
He retired from the army and moved with wife Ruth and baby son Jonathan to the Mandurah suburb of Dudley Park at the beginning of the campaign.
At a victory celebration in Pinjarra, Mr Hastie paid tribute to former member Don Randall.
"Everywhere I've been in the electorate I've seen the reflection of Don in the stories and lives of the people of Canning," he said.
"He did his best for people to improve their lives and often without fanfare.
"I have learnt many lessons from him from his service and leadership.
"Many people have said I have big shoes to fill. I hope to honour Don's memory."
Mr Hastie said he was humbled by the responsibility bestowed upon him by the people of Canning.
"This campaign was always about the people of Canning and their concerns," he said.
"London and Moscow are closer together than Perth and Canberra.
"While Labor tried to make this campaign about their political games, I tried to make this campaign about the people of Canning and their issues."
Mr Hastie said tackling ice in the community would be his primary focus as a local member.
"I want to get things done," he said.
"Many people are already hard at work in Canning. I want to work along side them and get things done," he said.
Mr Hastie thanked his wife Ruth and his baby son Jonathan.
"I'll make mistakes like any new member of parliament, but I will always try to do the right thing," he said.
The campaign was not without controversy.
In the last week of the election, Malcolm Turnbull was elected by the Liberal party room to replace Tony Abbott as Prime Minister after bringing on a leadership spill.
The ascension of Malcolm Turnbull to the prime ministership removed the key component of Labor's strategy, who were using the unpopularity of Tony Abbott as their focus in the campaign.
However, the Liberals concentrated on Mr Hastie's military experience, contrasting his career in the SAS against the background of his Labor opponent Matt Keogh, a corporate lawyer.
Neither Liberal or Labor candidate could cast a vote in the byelection. Both men moved to the electorate inside of the one month waiting period required under electoral laws.
Labor candidate Matt Keogh conceded defeat earlier in the evening at a function for supporters in Mandurah, thanking the voters of Canning and Labor branch members for their support.
Mr Keogh also claimed credit for the Liberal party's decision to replace Tony Abbott as Prime Minister.
"We did win the first war, we got rid of Tony Abbott," he said.
"I thank Labor and the union movement for trusting me to be their candidate.
"I would like to thank the branches in Canning, particularly the first branch I joined, the Armadale-Kelmscott branch.
"As you know, I was Canning born and bred.
"The fire within me to fight for my local area is greater now that it's ever been and I really wish to continue that fight into the future."