Real-estate brokers can no longer impose a fee on New Yorkers when they rent an apartment, the state says.

The ruling—made in legal guidance dated Jan. 31 and effective immediately—is a victory for renters who until now often have paid upfront broker costs, along with their security deposit and first month’s rent, that have made living in New York City increasingly expensive.

It...