Charlie Hales, the mayor of Portland, Ore., was running a zoning hearing last December when he missed a call on his cell from David Plouffe, the campaign mastermind behind Barack Obama’s ascent.

Although Hales had never met him, Plouffe left a voice mail that had an air of charming familiarity, reminiscing about the 2008 rally when 75,000 Obama supporters thronged Portland’s waterfront. “Sure love your city,” Plouffe gushed. “I’m now working for Uber and would love to talk.”

Hales, like many mayors in America, could probably guess why Plouffe was trying to reach him. Uber’s made a name for itself by barging into cities and forcing politicians to respond. It started in 2010, providing swanky rides at the tap of an app in San Francisco. “I pushed a button, and a car showed up, and now I’m a pimp,” Chief Executive Officer Travis Kalanick said four years ago.

The company has since expanded to take on lower-cost taxi service in more than 300 cities across six continents, ballooning to a $40 billion valuation. At the time of Plouffe’s call, Uber already operated in several Portland suburbs, and over the previous few months Hales’s staff had asked the company to please hold off on a Portland launch until the city could update taxi regulations. Plouffe may be a big name, but Hales didn’t immediately call him back.

The next day, City Hall heard from a local reporter that Uber cars would hit the streets that very evening. The company’s unauthorized kickoff put Hales in a bit of an artisanal pickle. Portland had just become the first city to explicitly allow short-term rentals through Airbnb and other sites, and welcoming Uber could help build the city’s sharing-economy brand, a logical extension of its communitarian roots. On the other hand, aggression is so not the Portland way.

Hales gathered Transportation Commissioner Steve Novick and three aides to call Plouffe. Hales would play the good cop to Novick’s bad cop. The roles were fitting: Hales comes off like the thoughtful baby boomer dad on Family Ties, while Novick’s known around town for his fiery wit. (In a campaign ad mocking the idea that voters should elect politicians who are relatable drinking buddies, Novick, who was born without a left hand, pops open a bottle of beer with his prosthetic metal hook. “Steve Novick,” the voice-over said. “He’s always found a way to get things done.”) The group huddled around Hales’s cell phone on speaker mode as the mayor dialed Plouffe.

A year ago, Colorado passed the first ride-sharing legislation in the country. Since then, about 50 U.S. jurisdictions have adopted ordinances recognizing Uber and Lyft as a new type of transit provider called “transportation network companies.” Each government, whether municipal or state, goes through its own process to craft rules, but in the end, officials generally codify the insurance coverage, background- check policies, and inspection protocols Uber already has in place. Uber makes the rules; cities fall in line. There are some small differences between their regulations, but, as Plouffe says, “the core is remarkably similar.”

The success, says Justin Kintz, Uber’s head of public policy for North America, is “a tale as old as time—it’s the power of the people.” It’s also a tale about the power of backroom lobbying. Although Uber promotes itself as a great disrupter, it’s quickly mastered the old art of political influence. Over the past year, Uber built one of the largest and most successful lobbying forces in the country, with a presence in almost every statehouse. It has 250 lobbyists and 29 lobbying firms registered in capitols around the nation, at least a third more than Wal-Mart Stores. That doesn’t count municipal lobbyists. In Portland, the 28th-largest city in the U.S., 10 people would ultimately register to lobby on Uber’s behalf. They’d become a constant force in City Hall. City officials say they’d never seen anything on this scale.

When Hales got through to Plouffe, he said he’d heard a “disturbing rumor” that Uber planned to start operations. “That,” he said, “would be a bad way to start.” Plouffe responded with a drawn-out silence. Before Plouffe mustered a reply, Novick erupted: “Mr. Plouffe, if you come to Portland without following our rules, we’re going to throw the book at you!” But as Portland would learn, a city of 600,000 can play tough with a $40 billion company, particularly one that is used to getting its way, for only so long.

Kicking off the pilot episode of the TV show Portlandia, actors Fred Armisen and Carrie Brownstein set the scene for the show’s satirical wet kiss to the city. Portland, they sing, is a magical place of awesome weirdness. “It’s like Portland’s almost an alternative universe,” Brownstein swoons. “In Portland, it’s almost like cars don’t exist. People ride bikes or double-decker bikes, they ride unicycles. They ride trams. They ride skateboards!”

The parody could double as an ad for the city’s transportation department. Among urbanists, Portland’s a transit darling. People can bike in protected lanes, ride the bus or MAX trains (one of the nation’s busiest light-rail systems), or tool around in Smart cars from car-sharing company Car2Go. But there are holes, especially for residents living far from downtown, the disabled, and late-night partyers.

The city’s taxis have been known to fall short of demand. Portland has fewer cabs per resident than most comparable cities, and drivers take home just $6.22 an hour, according to a 2012 survey. The taxi companies didn’t hold traditional political power as major campaign donors or lobbying forces, but their furor succeeded in resisting, or at least delaying, change. It took a nasty four-year battle for a group of largely immigrant drivers to get permits in 2012 to start Union Cab, a driver-owned cooperative.

Uber first targeted Portland in 2013, when it wanted to introduce its luxury car service, UberBlack. It couldn’t legally operate because a city ordinance required black-car trips to be reserved an hour in advance, the legacy of a 2009 agreement that carved out separate markets for hire cars and taxis. When Uber showed up, Hales had recently been elected, and his director of strategic initiatives, Josh Alpert, says overhauling the taxi rules was something on Hales’s first-term to-do list.

In a town Portland’s size, City Hall can juggle only so many issues. Alpert told Uber that before the city could deal with a taxi battle, it had to address more pressing matters, starting with the $21.5 million budget shortfall Hales inherited. “I explained to them that there was going to be a process, and we were nowhere near starting that process,” he says.

That didn’t sit well with Uber. “Portland has some of the most extreme protectionist laws that we’ve seen around the country,” Kalanick told a local TV station. A few days later, Uber defiantly said on its blog that “outdated local regulations” didn’t prevent it from making deliveries, so it ran a one-day promotion serving ice cream around town. It was like when the company shuttled puppies from shelters to offices in 10 cities before the Super Bowl. In City Hall, the ice cream tasted like belligerence. “It was like, ‘Whoaaaa,’ ” Alpert says. “I know every city says this, but we are not used to that in Portland. It was just all about Uber.”

Uber soon asked the city’s Private For-Hire Transportation Board—made up of industry reps, drivers, and community members—to remove the one-hour requirement. It also deployed some classic political strategies.

Plouffe likens customers to campaign volunteers, and the ice cream stunt provided the company with a database of consumers it could turn into advocates. In an era of low voter turnout, Uber has managed to get almost a million people to sign its petitions in the past year. “Not many private-sector companies have that kind of passionate set of consumers that will go the extra mile,” Plouffe says. In Portland, almost 1,700 people signed a petition to “tell Uber to bring their stylish rides to Oregon.” The company also solicited supportive letters from local business leaders.

Uber stopped pushing, as the company’s focus across the country was shifting from black cars to the low-cost uberX service, which fell under a different set of regulations. “Uber, to their credit, did go away for a while,” Alpert says.

When the company came back almost a year later, both the city and Uber had reason to think the negotiations would be fruitful. Uber had a new local face, General Manager for the Pacific Northwest Brooke Steger, whom Alpert calls “a much easier person to work with.” And Portland had just crafted the Airbnb rules, which established that the city wasn’t necessarily hostile to sharing-economy services.

Yet Uber was still Uber, and it began strangling Portland. It launched just to the north, in Vancouver, Wash. “Hey Portland,” Uber taunted on its blog. “We are just across the river.” Soon Uber started operating in several adjacent suburbs. “They basically forced their way into the market and surrounded us, then put the pressure on for us to do likewise,” Hales later told a conference of mayors.

The city told Uber that updating the taxi regulations could, finally, happen soon, but first the transportation department had to fix Portland’s pothole problem, which required finding millions of dollars in new revenue for the street maintenance budget. Around Thanksgiving, Uber was next in the queue. Uber wanted a firm time frame, which Alpert couldn’t give. “I kept telling them: ‘A little bit longer,’ ” Alpert says. “Strangely, at the last minute, when it was in sight, they were like, ‘Well, we’re done.’ ”

“If we end up in court, we will have to lose just based on resources”

After Plouffe’s call to Hales, Uber went ahead with its unsanctioned Portland launch, throwing a party in a loft to show, the invite said, how Uber was “proud to call Portland (and all of its rain, quirks, and bridges) home.” Partygoers could take photos with protest signs or stop by a postcard station to “drop a note to Mayor Hales.” Uber canned the kinder motto, #WeWantUberPDX. In the first four hours, more than 7,000 people signed a petition now asserting #PDXNeedsUber.

The company released a video with the most Portlandish introduction it could muster, featuring an Uber driver dramatically navigating in the rain, crossing a bridge over the Willamette River, and giving a ride to the Unipiper, a well- known local who rides a unicycle while wearing a Darth Vader mask and playing a fire-breathing bagpipe.

After a weekend of scrambling, the city sued Uber on Monday. Although Uber’s fines would eventually total $67,750, the city’s enforcement efforts evoked the Keystone Cops. Agents conducted stings, but Uber turned off the accounts of city staff so they couldn’t use the app. And at the time, the city believed it lacked the authority to impound cars. Still, the lawsuit captured attention. Portland residents on social media said the law-breaking felt “icky.”

Even the Unipiper backpedaled. “Wow, this whole #Uberpdx thing is really getting crazy,” he tweeted. “No they did not explain to me that they were going to launch illegally,” he wrote. “I do think Portland has been slow to act.” (About the legality of the launch, an Uber spokeswoman now says: “Often regulations fail to keep pace with innovation. When Uber launched, no regulations existed for ride-sharing.”)

Uber’s rules-be-damned approach had served the company fairly well around the country, but the Portland showdown came at a time of particularly intense scrutiny. An executive had mused aloud about spying on journalists, an alleged rape by a driver in India made headlines worldwide, and two California district attorneys sued Uber, claiming it misled consumers about driver background checks. And there was Novick, the transportation commissioner in a city known—even mocked—for being progressive, telling the New York Times that “Uber seems like a bunch of thugs.”

Uber hired a new team of local lobbyists headed by Dan Bates, who used to work as Portland’s own lobbyist in the state capitol. Across the country, Uber’s lobbyists have similarly intimate connections. In Kansas, it hired Governor Sam Brownback’s former campaign manager and another lobbyist who also works for Koch Industries. In Connecticut, it contracted with a former House speaker’s firm, and in Illinois it brought on the former governor’s chief of staff.

Soon, Alpert’s phone rang. It was Mark Wiener, whom one local alt-weekly dubbed “The Man in the Shadows” and the “most powerful political consultant” in Portland. Wiener helped both Hales and Novick get elected and is known to work only with clients he thinks will win. Wiener said Uber wanted to know if Hales and Novick would consider a détente. Would they be open to a “conversation about a conversation?”

On a Saturday in mid-December, the two sides met at Wiener’s house. The mayor started by saying the conversation would go nowhere unless Uber stopped breaking the law. “He said it probably five times,” Alpert says. Uber’s Steger and Caitlin O’Neill, an in-house lobbyist who used to work as an organizer for criminal justice reform at the American Civil Liberties Union, apologized. “That was a huge point for the mayor and commissioner to hear,” Alpert says.

Soon they sketched out a compromise. Uber would temporarily cease operations in Portland—a first for the company—and the city would put the lawsuit on hold and give Uber the deadline it wanted, promising to have a community task force figure out rules to get Uber back on the street by early April. It was a brilliant agreement. The city could look like it tamed Uber without costly litigation, and Uber cut in line and became a top political priority. It had a firm timeline, and if for some reason the process fell apart, Uber could say it tried to cooperate. The Wall Street Journal cited the agreement to show “How Sharp-Elbowed Uber Is Trying to Make Nice.”

And so Steger and O’Neill found themselves in a packed, fluorescent-lit city conference room in mid-January listening to a gray-haired facilitator kick off the task force with a long- winded joke about parrots and magicians. Over the coming weeks, the task force would hear a host of presentations, from the history of transportation in the city, starting with jitneys and the horse-drawn carriage, to testimony from taxi companies, drivers, and the public. Before various sessions, Uber mobilized its supporters. It hosted breakfast for drivers at a Nuevo Latino restaurant on the morning of their “listening session,” then drinks at an old-timey cocktail bar, Raven & Rose, before the public hearing.

In mid-February, O’Neill and Steger sat before the task force to formally pitch their case. Lyft, a competing company that has also been trying to enter the Portland market, was there, too. Again, Uber seemed firmly in control. “I’ve gone through this regulatory process that you all are going through now in several other counties,” O’Neill said leaning into the microphone. “We want to be a resource to you.” She and Steger then ticked through points designed to position Uber as a rule-abiding company that saves lives.

Uber’s policy group has its own team of data scientists, and its presentation included slide after slide of rosy graphics and numbers. To address Portland’s environmental bent, it showed how in San Diego, 30 percent of uberX rides start or end near a transit station. To show equitable service, it explained that Uber’s study in Chicago found wait times were consistent across the city, regardless of area income. To show drivers make livable wages, it introduced data from Princeton economist Alan Krueger, who served with Plouffe in the Obama administration, that found uberX drivers made more than $16 an hour (PDF).

The inundation of data made it hard to spot holes. The Chicago study was just for people who had the Uber app, so it didn’t address poorer riders who can’t use Uber because they don’t have smartphones, and Krueger’s big pay analysis didn’t ask about how much drivers spend on expenses such as gas and insurance, making it an incomplete earnings picture.

Before a late-February task force meeting, a weary-looking Alpert said there were so many issues to consider that he was trying to keep everyone focused on safety so Uber could still get provisional permits in early April. Other issues, he said, could be dealt with later. “We weren’t having luck stopping them,” Alpert said. “We won’t be able to keep them off the streets much longer.”

“We won’t be able to keep them off the streets much longer”

On April 9 the task force suggested a 120-day trial period for Uber. It recommended that the City Council accept the insurance Uber provides and let both taxis and ride-hailing apps choose their own background-check providers. The task force also allowed auto shops with fewer credentials to inspect both taxis and the ride-hailing vehicles. Yet there were inequities. Taxis had to carry more insurance, and their rates were capped, while Uber could jack up fares during foul weather or other peak times—a policy the company calls surge pricing. At least 10 percent of the taxi fleet had to be wheelchair-accessible, while Uber could direct wheelchair-bound passengers to transit companies that serve the disabled.

The taxi industry and its supporters cried foul. One driver compared Uber to Enron because it “doesn’t play by the rules.” A man who regularly attends council meetings and calls himself Lightning said that Uber was already worth billions. “That is what you value the most,” he said, arguing that Uber should make a “reasonable offer” to Portland taxi drivers who lose business.

The proposal needed support from at least three commissioners to pass. The whole process was Hales’s and Novick’s baby, so they provided two likely votes. Amanda Fritz would be a long shot. She was particularly progressive, and her husband had recently died in a car crash, making her vigilant about drivers carrying adequate insurance. Nick Fish wasn’t buying the whole sharing-economy concept—he was the sole commissioner who didn’t vote to allow Airbnb. That left Dan Saltzman, the long-serving council member who championed wide-ranging rules for Airbnb. One City Hall staffer describes Saltzman as the closest thing Portland has to a free-market conservative.

Uber had been working on the council members for months. “They kinda run this,” Alpert said in February. “I keep feeling they will just wear you down. If we end up in court, we will have to lose just based on resources.”

Records show the company had 19 in-person meetings with city officials in the first three months of the year, including one at the end of March, when Uber brought back the big gun, Wiener, to meet with Saltzman, the likely swing vote. Wiener had consulted on Saltzman’s past campaigns. All the meetings, combined with phone calls, meant Uber spoke with City Hall on average almost every other workday. E-mail traffic was even heavier. The city hasn’t released the correspondence, which Bloomberg Businessweek requested in early April, saying it’s taken longer than expected because Uber and city staffers exchanged about 300 e-mails that may fall under the request.

As a gesture of good faith, Uber paid its outstanding fines, and the council scheduled the vote on a proposal Novick and Hales submitted in mid-April that echoed the task force’s suggestions with a few tweaks, notably removing the rate cap for taxis. The morning of the vote, Uber hosted a breakfast for about a dozen drivers at a downtown restaurant, then marched the group to City Hall, with TV news cameras in tow. City Council was in session, so an Uber communications manager instructed them to leave a note in the council office. That evening, they returned for official testimony. Both Uber and taxi reps were out in force, with three hours of public comments. “#PDXRides hearing in nutshell,” tweeted Oregonian transportation reporter Joseph Rose. “Uber drivers: Portland taxis never show up. Cabbies: Uber drivers are rapists, burglars, criminals.”

In the end, the council approved the 120-day trial period. Saltzman cinched the vote. That Friday, Uber started operating again. The council is slated to take up permanent regulations, with updated requirements for serving passengers in wheelchairs, in late summer.

On April 29, Uber threw a second launch party, this time at a hand-harvested sea salt factory. Duck breasts with pistachio butter and huckleberry sauce were served; the photo booth no longer had protest signs. Three City Hall aides attended.

The next day, Plouffe and Hales shared the stage at an event organized by TechFestNW. Back in December, Alpert had said he wasn’t having luck getting Plouffe to attend the conference, which is Portland’s answer to Austin’s South by Southwest. Now on stage, Plouffe and Hales were all smiles. Hales teasingly tossed a copy of the negotiating bible Getting to Yes to Plouffe, a nod to Novick’s “we’ll throw the book at you!” threat.

Plouffe told the audience that playing nice in Portland isn’t necessarily a model elsewhere. “Maybe it is. Maybe it isn’t,” he said. Despite its wins, Uber still has plenty of battles left in the U.S., not to mention abroad. It’s recently backed out of places like San Antonio, where it says new rules are too onerous.

It’s nearly impossible to calculate Uber’s ground war costs because many cities and states don’t require the disclosure of lobbying costs. Those that do show that influencing policy doesn’t come cheap. Take Texas. In 2013, Uber had no registered lobbyists in the state. Last year, it reported 14, and so far this year, that’s grown to 28 who have registered to work on Uber’s behalf, with contracts that could total $420,000 to $945,000, according to the filings, more than Philip Morris and Pfizer. In the past year, Uber spent $208,000 in Maryland and $684,000 in California.

City-level battles can be costly, too. Last year, Uber put more than $600,000 into a voter referendum in Seattle and spent $314,000 lobbying in Washington, D.C. The Portland campaign looks quaint by comparison. Uber reported spending about $68,000 on outside lobbyists in Portland and Oregon in the last two quarters.

Just days after the festival, Uber sent an urgent message to Portland users through its app. A bill the taxi industry supported in the Oregon statehouse would require higher insurance coverage. “Portland spent months creating thoughtful regs to welcome ridesharing!” Uber wrote. “Now that’s in jeopardy. Help keep it around.” Attached was a link to a petition, addressed to every member of the legislature.

—With Eric Newcomer and Olga Kharif

This article was written by Karen Weise from Bloomberg and was legally licensed through the NewsCred publisher network.