The new law claims to protect "public order, security, health, and cultural value" and empowers local authorities to designate areas as out-of-bounds for homeless people, as well as evict people living in huts or shacks.
Offenders can be punished with community service, fines or even imprisonment.
Hungary's treatment of the homeless has triggered criticism from rights campaigners and international bodies including the Venice Commission, an advisory body to the Council of Europe.
Earlier this month New York-based watchdog Human Rights Watch cited Hungary's laws on homelessness as an example of Budapest's "undermining" of EU law and human rights since Prime Minister Viktor Orban's right-wing government came to power in 2010.
The latest law is "primarily in the interest of homeless people," a statement from Orban's office insisted Monday.
Instead of staying in hostels "they rather choose to stay in public areas where they risk freezing to death during the winter," the statement read.
The government says funding for programmes and facilities helping the homeless has increased, while hostel places are adequate to cater for the homeless population -- estimated at over 4,000 in Budapest alone.
Last November Hungary's constitutional court judged an earlier clampdown on rough sleeping was unconstitutional, but in March this year parliament voted to amend the constitution to reinstate the restrictions.
Before Monday night's vote, several hundred homeless people and activists staged a protest outside parliament.
"This is a social issue, not a criminal one," Tessza Udvarhelyi, an activist with The City Belongs to Everyone rights group told AFP.
"Authorities should help vulnerable homeless people find dignified accommodation and work rather than punish them," Udvarhelyi said.
"It is a lie that there are enough hostel places for all, and what does exist is often not safe, clean, or dignified," she added.
Udvarhelyi said the group will turn to Hungary's rights ombudsman and president in a bid to repeal the law.