Scott Shatford didn’t bargain for criminal charges.

The official complaint arrived at his front door in May, more than a year after Santa Monica, California, voted to ban the short-term home rentals flooding its small beachside community. Shatford knew the rules but had chosen to ignore them, continuing to list two properties for short stays on Airbnb. He found the city’s ban ridiculous and assumed it would be difficult to enforce. Even if he did get caught, Shatford figured a few fines would be a small price to pay for properties earning him around $60,000 a year.

But Santa Monica came down hard. After Shatford failed to respond to multiple warnings and fine notices—sent to rental property mailboxes he never checked—the city filed a criminal complaint against him. Local officials called Shatford an “egregious” violator who repeatedly defied citations and “boasted publicly” that Santa Monica would be unable to enforce its own law.

From there things moved fast. In July, Shatford became one of the first Airbnb hosts in the US to be convicted for renting out units illegally. He agreed in a plea deal to stop listing apartments, pay the city about $3,500 in penalties, and be placed on two years’ probation. That same month, Shatford closed down his rental operation and moved to Denver.

“I expected fines,” he says. “I really wasn’t expecting them to start to make criminals out of people that were just trying to make a living.” On Sept. 2, Airbnb sued Santa Monica over its ban in federal court.

What happened in Santa Monica wasn’t an isolated incident. Airbnb’s peer-to-peer rentals are being scrutinized in Los Angeles; Miami Beach, Florida; Portland, Oregon; Toronto; Barcelona; and Berlin. In its hometown of San Francisco, a federal judge on Nov. 8 upheld rules could levy hefty fines on its platform. In New York, the company’s largest US market, governor Andrew Cuomo in October signed into law some of the toughest limits on short-term apartment rentals in the country. The backlash comes right as Airbnb is looking to transform itself into a full-service travel firm, and as it inches toward an inevitable IPO. The company isn’t taking it well—its lawsuit against Santa Monica was one of four complaints Airbnb lodged against US cities this year.

Quartz/Alison Griswold People protest Airbnb outside of New York City Hall in November 2016.

Airbnb began in San Francisco in 2007 as three guys with a couple of air mattresses and an empty loft, trying to scrape together rent. Like any good origin story, Airbnb’s came to epitomize its business: helping people earn a little extra money and providing more lodging options for tourists. It was a potent concept back then, as millions of people were losing their jobs, homes, and life savings to the recession. Airbnb and another young startup, Uber, promised a reimagining of the American dream when the country needed it most.

For almost a decade, Airbnb has stuck carefully by that message, while maturing from a scrappy startup into the world’s fourth-most valuable private tech company. On paper, Airbnb is worth $30 billion, as much as Marriott International, the world’s largest hotel chain. At the same time, the company brands itself to hosts, guests, and investors as a champion of the middle class. Its founders and executives speak often of empowering families to pay their bills, and making it possible for people to stay in their homes. In its own telling, Airbnb is the clear good guy—a startup providing a financial lifeline, an economic boost, and a tool to make ends meet. The villains are those who stand in the way of innovation, chiefly the hotel lobby.

This year has proved that narrative messier in reality. In Santa Monica and beyond, the boom in home-sharing is finally being noticed, not just by Airbnb’s supporters, but by the many, many people who care about housing. Legislators are wondering whether Airbnb is good for the residents who vote in their districts, or just a boon to tourists passing through. Tenants in densely packed apartments are worried that a flurry of out-of-towners is decreasing their safety and disturbing their quality of life. In places where rents are already high and affordable units hard to come by, housing advocates fear the platform is encouraging profit-hungry landlords to turn their properties into makeshift hotels.

After years of playing the nice guy, Airbnb now finds itself on the defensive in some of its biggest markets, and the pressure doesn’t suit. The company has unleashed lawsuits, held rallies, and spent millions on lobbying campaigns. It has decried political adversaries and brandished opposition research on hotels. The clashes lay bare an ugly truth: Under fire, Airbnb is a corporation like any other. It’s not that nice at all.

Things were simpler when Shatford started hosting in October 2012. An adolescent tech startup valued in the mere single-digit billions, Airbnb was hardly on Santa Monica’s radar. It was building its brand as a friendlier, cheaper alternative to hotels, and Shatford was in many ways the prototypical host: a guy who needed financial help after losing his job in corporate America. After listing his apartment on Airbnb, Shatford booked a one-way ticket to Thailand and, funded in part by earnings from the rental, spent the next six months traveling around Southeast Asia.

Once Shatford returned to the US, he realized that, with a bit of time and effort, renting on Airbnb could be made extremely profitable. “The opportunity kind of slapped me upside the head, and I dove into it full force,” he says. Shatford worked on his Airbnb copywriting, revamped his photos, and experimented with pricing. “I figured out that I could make $4,000 a month in profit off that place.”

The next summer, Shatford started to expand in earnest. “I would break even on a property in like two months, and I would have enough money to open another property,” he says. By mid-2014, Shatford had secured enough leases to run seven Airbnb listings. “I had this whole arbitrage,” he says. “It was my main job, and a well-paying job.” He also started a side gig, a website called Airdna that scraped and analyzed data from Airbnb listings.

Even as he made a career of hosting, Shatford never met anyone from Airbnb, and didn’t really expect to. He was, after all, just another host on a fast-growing technology platform. So it took him by surprise when, one day in early 2015, he was notified that Airbnb chief marketing officer Jonathan Mildenhall had booked a stay at one of his listings. Shatford worried the exec would frown upon his spate of rental properties, or his data-scraping venture. But when Mildenhall arrived, the two hit it off.

“We had an hour chat,” Shatford says. “He said, if you’ve got five or less properties, we probably aren’t going to get to that anytime soon. There was some concern internally that people who were managing, you know, dozens of properties professionally, they were catching heat and they might crack down on that at some point in time. He basically did tell me that large-scale could be potentially a problem down the line, but kind of small-time wouldn’t really be on the radar for a while to come.” A spokesman for Airbnb said Mildenhall does not recall having this conversation.

Courtesy/Scott Shatford Scott Shatford’s Airbnb listing that was booked by Airbnb CMO Jonathan Mildenhall.

Santa Monica was also wising up. In an April 2015 meeting, city officials noted that short-term rentals had “proliferated.” They were particularly concerned about “vacation rentals”: entire homes that could be booked on Airbnb and similar sites for fewer than 30 days. Legislators resolved to explicitly ban vacation rentals, which they worried were taking units off the market for longer-term residents. They agreed to continue letting people host visitors in their spare rooms if they obtained a business license from the city first. The new rules passed unanimously in May, and took effect in June.

Santa Monica’s push to curb short-term rentals came as other cities were waking up to the surge in home-sharing. In March 2015, a report from Laane, an organizing group in Los Angeles, warned that Airbnb had “pit tourist dollars against renter dollars” by creating a platform where “landlords can potentially earn significantly more money by converting traditional rental stock into Airbnb units, as many appear to have done.” In San Francisco, lawmakers imposed limits on home-sharing and required hosts to register with the city.

Michael Castaldo Tenants in Chelsea posted a sign to remind Airbnb guests that they are staying in a residential building.

Tensions were particularly high in New York, where Airbnb had come up against a 2010 law designed to prevent landlords from clearing out tenants and converting residential buildings into more profitable accommodations for tourists. Lawmakers were angered by Airbnb’s refusal to comply with this “illegal hotels” law, which prohibited New Yorkers from renting out entire apartments for less than 30 days. Tenants, meanwhile, complained that Airbnb guests were making a ruckus, leaving doors unlocked, and putting trash in the wrong places.

“We didn’t sign a lease that we were living in a hotel,” says Michael Castaldo, who has lived in the same apartment in Manhattan’s Chelsea neighborhood for more than two decades. Castaldo and his neighbors have lodged multiple complaints about Airbnb activity in the building, and placed emphatic signs in the lobby to remind visitors that they are staying in a residential apartment.

In city after city, Airbnb has argued that home-sharing is used mainly by everyday people trying to make ends meet, and opposed mainly by hotels. And it’s true that hotels aren’t Airbnb’s biggest fans. Last year, Pebblebrook Hotel Trust CEO Jon Bortz said on an earnings call that Airbnb was limiting his ability to charge “gouging rates” during popular events. New York City-based ShareBetter, a prominent anti-Airbnb group funded in large part by the hotel lobby, has spent $1.5 million fighting home-sharing since September 2014.

“The places where there are challenges happen to be the epicenter of the hotel cartel,” Chris Lehane, Airbnb’s head of global public policy and a former Clinton administration operative, told Quartz in late October. “We know that the hotel industry is out there running a full-fledged campaign.”

That argument never flew with lawmakers, who felt Airbnb was being disingenuous, and refusing to follow rules that would force it to crack down on professional, multi-unit hosts. Airbnb makes money on each reservation—a 3% cut from the host and a 6%-12% service fee from the guest—so more bookings means more revenue, and hosts with multiple listings can make for a lot of bookings. In October 2014, a report from New York’s attorney general concluded that the 6% of New York City Airbnb hosts renting out three or more units brought in 37% of all host revenue.

“They’re following this giant corporate America playbook and they’re pretending that they’re a bunch of nice guys who came up with a cute idea to save themselves money when they were post-college,” says Liz Krueger, the New York state senator who sponsored the 2010 illegal hotels bill.

By late last year it was clear that, without a new tack, Airbnb risked permanently alienating governments in some of its biggest markets. In November, after a hard-won victory over a San Francisco ballot initiative to restrict home-sharing, the company unveiled its “Community Compact,” a four-page pledge to embrace transparency, work with cities, and build a company “of the people, by the people, for the people.” Airbnb said it would take concerns over multi-unit hosts more seriously, and purge the worst offenders from its platform, starting in New York.

Many cities were already taking that purge into their own hands. In April 2016, San Francisco’s budget and legislative analyst found that a quarter of short-term-rental hosts were breaking local rules, even though the city had doled out $680,000 in penalties over the past year. In May, Berlin enacted restrictions on entire-home rentals that included fines of up to €100,000, which the head of urban development called “a necessary and sensible instrument against the housing shortage.” In Miami Beach, a city-led crackdown on short-term rentals produced $1.6 million in fines in just five months. In June, New York’s state legislature voted overwhelmingly to tighten the rules Airbnb had refused to follow, making it illegal to even advertise an entire apartment for rent for less than 30 days.

The national attention peaked in July, when Massachusetts’ Elizabeth Warren and two other US senators penned a letter calling on the Federal Trade Commission to “study and quantify” commercial activity on home-sharing platforms. “On the one hand, these firms have sparked innovation, increased competition, and have provided new means by which our constituents can earn extra income,” they wrote. “On the other hand, we are concerned that short-term rentals may be exacerbating housing shortages and driving up the cost of housing in our communities.”

Airbnb promoted a different view. The company commissioned and published studies arguing that its listings account for too few housing units to significantly affect rents or overall supply. It touted the “sensible” home-sharing rules established in cities such as Philadelphia, Chicago, and New Orleans, while launching lawsuits against San Francisco, Anaheim, and Santa Monica. It became a hotel watchdog, tracking when execs celebrated high room rates and accusing a leading hotel group of “a long history of fighting unions.” Airbnb rallied its hosts and led expensive campaigns to beat back legislation; in New York alone, it funneled roughly $11 million into its “Stronger Neighborhoods PAC.”

“I think we have an obligation, when the special interests are trying to create a situation that is really detrimental to middle-class hosts trying to make ends meet, to stand and fight for them,” Lehane said in late October, days after the company sued New York for signing stricter short-term rental rules into law.

And then, suddenly, Airbnb caved. On Nov. 1, the company introduced a “One Host, One Home“ feature in New York and San Francisco that prevented hosts there from listing more than one entire home, reversing a long-held stance that self-policing would be cumbersome and logistically unrealistic. Last week, it agreed in a deal with London and Amsterdam to ensure hosts meet local licensing requirements and to enforce caps on the number of days an entire apartment can be rented out each year. On Dec. 2, Airbnb also settled with New York City, agreeing to drop its lawsuit in exchange for the city promising to only fine hosts for rental violations, and not the company itself.

Linda Rosenthal, the state assemblywoman who authored New York’s legislation, called it “an astounding about-face.” Airbnb characterized it as ”a material step forward for our hosts.”

Resolving controversies around entire-home rentals is imperative for Airbnb. As of this October, such listings accounted for 66% of the company’s US business, according to data from Airdna, Shatford’s analytics company. Rentals of private rooms, which tend to be fine with regulators, made up just 32% of the company’s inventory that month. Shared rooms accounted for a mere 2%.

Last month in Los Angeles, Airbnb convened its third Airbnb Open, a three-day conference-slash-festival that celebrated “the spirit of the Airbnb community.” There were appearances from actor Ashton Kutcher, who confessed to living in Airbnbs after divorcing Demi Moore, and actress Gwyneth Paltrow, as well as performances by Lady Gaga and Maroon 5. At the keynote event, Airbnb CEO Brian Chesky unveiled Trips, a concierge-like feature that helps travelers line up activities during their bookings, from truffle-hunting to playing with Samurai swords.

AP Photo/Willy Sanjuan Gwyneth Paltrow at the Airbnb Open in Los Angeles on Nov. 19.

Trips, or “Magical Trips,” as it was dubbed internally, is one of several steps Airbnb is taking to transition from home-sharing startup to all-in-one travel service. The company is also pushing into new markets like China and India, courting business travelers, and brokering deals between landlords and their tenants for new inventory. In the US, where just 1% of adults made money by sharing their home last year, Airbnb is building out a program that lets top-rated hosts manage rentals for other hosts in the area in exchange for a 10%-20% cut. All of this makes for a crucial next act, which Airbnb must pull off to convince investors it’s worth the $30 billion valuation it attained this summer.

Airbnb is moving away from, or at least beyond, its founding promise of being a platform for the middle class. It’s becoming more professional, more like the very hotel chains it seeks to upend. For the most part, that transition makes sense: Airbnb is no longer a new player. It has 2.5 million listings across 191 countries and 1 million guests staying in them on any given night. Like many a successful startup before it, Airbnb now has far more stakeholders to answer to. But the company still rests its appeal on bettering the lives of everyday people, and that mantra feels increasingly outdated amid a host of corporate imperatives.

The prospect of an IPO has likely intensified that soul-searching, and prompted Airbnb’s recent string of concessions. The company was said to have discussed regulatory challenges as risks with investors during its latest fundraising effort, though Airbnb declined to comment on that matter. One investor characterized regulatory risks to Quartz as real but “manageable.” Another source close to the company said investors strongly believe Airbnb’s popularity will enable it to reach compromises with city regulators. Those deals are necessary for more than Wall Street: Operating in a legal gray area, and the threat of fines or criminal charges, could reduce the appeal for potential hosts.

Maybe not for Scott Shatford. While he hasn’t resumed any rental activities since moving to Denver, choosing to focus instead on Airdna, Shatford says he’s keeping one eye on the housing market for a chance to jump back in. Colorado’s burgeoning legal-marijuana industry has made the city a popular tourist destination, after all, and home-sharing is permitted by local rules.

“I like to be at the front of the charge, running full force into the bayonets,” Shatford says, adding that he bears Airbnb no ill will for what happened in Santa Monica. ”It’s definitely not the end of my hosting career.”

Correction: An earlier version of this article misstated that a judge in San Francisco upheld rules that would fine Airbnb hosts. The rules could result in fines for Airbnb. It also misspelled the last name of Michael Castaldo as Castalado.