Only four MPs did not back the legislation, which comes after the country voted overwhelmingly in favour of legalising same-sex marriage last month.
Onlookers in the packed public gallery cheered loudly and started waving their rainbow flags while singing “I Am Australian”.
“We are one, but we are many
“And from all the lands on earth we come
“We’ll share a dream and sing with one voice