Airbnb is taking its hometown to federal court.

The company has filed a lawsuit against the city of San Francisco, objecting to short-term rental rule changes approved by its Board of Supervisors.

A new ordinance set to take effect in late July would require all Airbnb hosts to register with the city. If they do not, Airbnb would be fined up to $1,000 a day for each listing, putting the burden on the company to make sure each listing is legal.

But the city's $50 registration process is analog enough to turn off many hosts. It can't be completed online and requires submitting all the documents in person.

Airbnb contends the new rule violates the Communications Decency Act, Stored Communications Act and the First Amendment.

"While we have attempted to work with the City on sensible, lawful alternatives to this flawed new ordinance, we regret that we are forced to now ask a federal court to intervene in this matter," the company said in the blog post.

Related: Why everyone is cracking down on Airbnb

Airbnb described the action as an unprecedented step for the company, but said it believes "it's the best way to protect our community of hosts and guests."

Representatives of the San Francisco city government were not immediately available for comment.

Critics of Airbnb have long claimed that services like Airbnb remove affordable housing from the market by turning rentable apartments into unofficial year-round hotels.

It's a problem that scores of major cities are grappling with.

Los Angeles has taken action against some rent-controlled apartments that have been illegally converted into short-term rentals.

And a pending New York bill would make it illegal for many people to list their apartments on sites like Airbnb. Hosts violating the ban would face fines up to $7,500. Airbnb says more than 40,000 hosts could be subject to the fines.

-- Heather Kelly contributed to this report.