Prime Minister Malcolm Turnbull has defended giving $5 to a beggar in Melbourne, putting him at odds with the city's lord mayor who says giving money to people on the street entrenches homelessness.

Mr Turnbull was photographed on Wednesday putting a $5 note in the cup of a homeless man as he was arriving to give a major speech to the Committee for Economic Development of Australia.

Mr Turnbull was asked by 3AW radio host Neil Mitchell why he gave the man money when people are advised not to do so.

"I know people have got different views on that, but every time I see someone in that situation I always think, 'There for the grace of God go I'," Mr Turnbull said.