DALLAS—Texas is moving closer to enacting one of the nation’s toughest immigration laws after legislators approved a bill barring municipalities and police departments from adopting sanctuary policies for undocumented immigrants.

Under the legislation, which Gov. Greg Abbott has promised to sign, local law-enforcement officials could face criminal penalties if they don’t comply with requests from federal authorities to detain illegal immigrants.

...