The measure also will allow those who were previously convicted or are serving sentences to ask a court to dismiss and seal the record of the conviction.
Similar legislation became law in New York last year in what Wiener said is part of a broader effort to end violence toward and discrimination against sex workers.
"Everyone — no matter their race, gender or how they make a living — deserves to feel safe on our streets," Wiener said in a statement thanking Newsom.
Wiener, Newsom's fellow Democrat, used a parliamentary manoeuvre to delay Newsom's consideration for months after the bill passed the Legislature in September. He hoped the pause would give proponents time to build more support, including by signing an online petition.
Opponents like the California Family Council countered with their own online petition as part of a months-long tug-of-war.
The American Civil Liberties Union of California sought the legislation, along with several groups backing transgender sex workers and others in the sex industry. It has support from public defenders, Los Angeles County District Attorney George Gascón, San Francisco District Attorney Chesa Boudin and numerous criminal justice reform groups. Voters recently recalled Boudin amid a campaign labelling him as soft on criminals.
The loitering law allows police "to criminalise otherwise legal activities like walking, dressing or standing in public", the ACLU said.
Moreover, workers who fear arrest for loitering "are more vulnerable to exploitation and violence, and face greater barriers to accessing safe housing and legal employment", the group argued.
The nonpartisan National Center on Sexual Exploitation took the opposite view, saying that ending the law would make it easier for traffickers and sex buyers to exploit vulnerable people.