There are 150 politicians in the lower house - the government holds a majority of 76 seats to Labor's 69, with a crossbench of five.
Andrew Wilkie, Bob Katter and Nick Xenophon Team's Rebekha Sharkie all voted with Labor.
Independent MP Cathy McGowan missed the final vote by a matter of seconds. She was driving home to Victoria, but turned back and planned to vote with Labor in favour of a banking royal commission. With her support the final vote would have been 73-73.
The prime minister says the government was "caught out" by Labor's surprise tactics and blamed the chaos on three government ministers who missed the vote: immigration minister Peter Dutton, social services minister Christian Porter and justice minister Michael Keenan, who was on a flight home to Melbourne.
Porter arrived for the second vote, but Dutton didn't return to the floor until the fourth, which gave the government the numbers it needed to regain control of the lower house.
Keenan flew back to Canberra after landing in Melbourne, but arrived after the house had finally been adjourned after 7pm.
"This was a stunt by the Labor party who are far more interested in playing parlour games in Canberra than they are about representing the people that they were sent here to represent," Keenan told the ABC's AM program.
"I have no doubt that will be a lesson, there's a lesson for me and others and we won't be having a repeat of that."
Christopher Pyne is in charge of making sure politicians turn up to vote and says it was a "stuff up", but added he didn't give anyone permission to leave early.
Conservative liberal backbencher Andrew Hastie said Labor was playing "silly buggers", but conceded the government need to be "more disciplined".
Fellow Liberal backbencher Trent Zimmermann admitted it's not what the government wanted to happen in the first week of the 45th parliament.
But Tony Abbott said it provided a lesson for the Coalition, especially Malcolm Turnbull.
"All of us are learning lessons all the time, whether you're a journalist, a member of parliament, a whip or even a prime minister," Abbott said.