Squatters will face up to six months in prison and so-called squatters' rights scrapped as it becomes a criminal offence in England and Wales.
Ministers said the move would shut the door on squatters once and for all and help protect hard-working homeowners.
But campaigners warned that criminalising squatting in residential buildings would lead to an increase in some of the most vulnerable homeless people sleeping rough.
The introduction of the offence - which will carry a maximum sentence of up to six months in jail for persistent offenders, a £5,000 fine or both - follows a Government consultation on the issue last summer.
But homeless charity Crisis said the new law would criminalise vulnerable people, leaving them in prison or facing a fine they cannot pay.
"It also misses the point," Leslie Morphy, the charity's chief executive, said. "There was already legal provision that police and councils could, and should, have used to remove individuals in the rare instances of squatting in someone's home.
"And the new law also applies to empty homes - of which there are 720,000 in England alone, including many that are dilapidated and abandoned - criminalising homeless people when they are just trying to find a place off the streets. Ultimately the Government needs to tackle why homeless people squat in the first place by helping not punishing them."
But justice minister Crispin Blunt said: "For too long, squatters have had the justice system on the run and have caused homeowners untold misery in eviction, repair and clean-up costs. Not any more. Hard-working homeowners need and deserve a justice system where their rights come first - this new offence will ensure the police and other agencies can take quick and decisive action to deal with the misery of squatting."
Housing minister Grant Shapps added: "No longer will there be so-called 'squatters' rights'. We're tipping the scales of justice back in favour of the homeowner and making the law crystal clear: entering a property with the intention of squatting will be a criminal offence.
"And by making this change, we can slam shut the door on squatters once and for all."