The speaker of New Zealand's parliament has become a social media sensation, after images of him cradling a colleague's baby as he presided over a debate went viral.

Trevor Mallard, speaker in the country's House of Representatives, posted an image on his Twitter page of him feeding MP Tamati Coffey's newborn son while in the speaker's chair.

He captioned the snap: "Normally the Speaker's chair is only used by Presiding Officers but today a VIP took the chair with me. Congratulations @tamaticoffey and Tim on the newest member of your family."

The pictures have since been shared and liked hundreds of times, with many hailing Mr Mallard for taking on the babysitting duties.

Mr Coffey's son was born via a surrogate to him and his partner Tim Smith in July.

Other MPs also rushed to praise Mr Coffey for bringing the baby into the parliament chamber and shared an image of him holding his son.

"Lovely to have a baby in the House, and what a beautiful one," said fellow Green Party MP Gareth Hughes.

New Zealand's prime minister Jacinda Ardern made history last year by becoming the first female world leader to bring her baby to the United Nations general assembly.

And in the UK, Liberal Democrat leader Jo Swinson cradled her baby on Parliament's famous green benches in January - in what was thought to be a first during a Commons debate.

But not all countries are so relaxed about allowing babies in parliament.

Kenyan politicians walked out in protest earlier this month over a decision to eject their colleague who was holding her young child during a session of the legislature.

Zulekha Hassan Juma was ejected from the floor of the National Assembly with her five-month-old baby.

Christopher Omulele, temporary speaker of the National Assembly, said: "As much as she might want to take care of her child, this is not the place for it."