San Francisco has sued the state of California in an effort block a law that allows drivers for ride-hailing companies such as Uber and Lyft to dodge local business licensing requirements.

San Francisco City Attorney Dennis Herrera filed the lawsuit Thursday in the California Superior Court, asking that the court invalidate portions of Senate Bill 182. That law, which went into effect in January, makes it so ride-hailing drivers do not need to get licenses for each city and county they drive through, and instead only need to register in the municipality where they are technically “domiciled.”

San Francisco’s lawsuit contends that the new law “usurps” the city’s ability to regulate its businesses and could cause the city to lose millions in revenue.

“Uber and Lyft need to play by the same rules as every other business in San Francisco,” Herrera said in a statement to the press. “Nearly everyone, from a professional dog walker to Google, has to register their business. Uber and Lyft’s attempt to carve out a special exemption for their drivers is not fair to consumers, competitors or taxpayers.”

Along with asking to have portions of the law invalidated, the lawsuit also contends that the law is unconstitutional, and requests that the court bar the state from applying or enforcing the law.

According to the 14-page complaint, San Francisco requires independent contractors to pay an annual business registration tax if they drive in the city for at least seven days during the year. The tax is typically $90.

According to the complaint, the city tax collector suspected 57,000 ride-hail drivers had been operating in San Francisco in 2016, but, as of January, only 21,000 ride-hail drivers obtained business registration certificates from the city. Those registrations resulted in about $2 million in revenue to the city.

The complaint also said the number of ride-hail drivers has grown exponentially over the past few years and that has caused problems for the city, such as increased congestion, wear and tear on the highways, and more distracted drivers driving within the city.

The new law, according to the complaint, not only violates the state constitution by impeding the city’s ability to regulate its own businesses, but it also disproportionately affects San Francisco. Herrera contended in the complaint that, with its high real estate prices and the fact that the city is a popular tourist destination, San Francisco sees a significantly higher portion of ride-hail drivers coming from outside the city than most other municipalities.

“In San Francisco, our tax laws apply fairly to all businesses. I can’t stand by and watch our authority be eroded under false pretenses,” San Francisco Treasurer and Tax Collector José Cisneros said in a press release. “If Uber and Lyft are so concerned about the burden of registration on their drivers, they could hire them as employees, or push the state to create a statewide licensing system.”

A spokesperson for Lyft said in a statement: “SB 182 allows California rideshare drivers to hold one streamlined business license with predictable costs and reasonable privacy protections. Lyft drivers and the overwhelming majority of legislators from both parties supported these improvements to modernize the law and preserve the benefits and economic opportunities ridesharing provides.”

A representative from Uber did not return a message seeking comment. The press office for the California attorney general also did not return a message seeking comment.

Cheryl Miller in Sacramento contributed reporting.

The complaint is posted below: