Last December, Uber’s self-driving cars hit the rain-slicked streets of San Francisco with much fanfare. It was meant to be a watershed moment — the upstart ride-hail company bringing autonomous driving to its city of origin, years before most experts predicted we’d begin to see self-driving cars en masse.

But it turned out to be a total flop. A week after Uber’s fleet of 16 luxury Volvo XC90 SUVs started picking up passengers, the program was brought to a grinding halt. The California Department of Motor Vehicles revoked Uber’s vehicle registrations after Uber refused to obtain a $150 permit authorizing it to test driverless cars in the state. And rather than correct what on the surface seemed like a clerical error, Uber refused to get licensed, instead shipping its autonomous fleet to Arizona where it could test its self-driving cars with less public scrutiny.

It turns out that all this drama was preordained months in advance. According to a lengthy email exchange between Uber and the DMV obtained by The Verge from a public records request, Uber was repeatedly urged to sign up for the state’s autonomous testing permit, with the DMV even offering to expedite the process to make it as quick and seamless as possible. Had it done so, Uber could have saved itself a lot of embarrassment and could be offering trips in self-driving cars in San Francisco right now.

But in multiple emails to the DMV, Anthony Levandowski, vice president at Uber’s Advanced Technologies Group and the company’s top executive in charge of autonomous technology, argued that what it was doing did not meet the legal definition of autonomous vehicle testing, spurring a brain-bending debate over the letter of the law. The debate ended inconclusively, and Uber ultimately launched its doomed public pilot without ever notifying state regulators of its intentions to invite members of the public into the backseat of its self-driving cars.

“we decide what’s autonomous. And under our regulations, it was.”

“In their minds, they really thought they weren’t autonomous,” Jessica Gonzalez, assistant deputy director of public affairs at the DMV, told The Verge. “But we decide what’s autonomous. And under our regulations, it was.”

In recent days, Uber has come under intense scrutiny thanks to an explosive lawsuit filed by Google’s self-driving spinoff Waymo. Levandowski, a former Google engineer, is accused of stealing the company’s technology before starting his self-driving truck startup Otto, which was subsequently acquired by Uber for $680 million. Google is seeking to block Uber from testing its self-driving cars, while Uber has denied all the charges.

California started requiring companies testing autonomous vehicles on public roads to get permits in 2014. Since then, nearly two dozen companies have registered, including Google, Tesla, Ford, Mercedes-Benz, and Volkswagen. Companies are not required to disclose in their applications where they plan to do their testing. Nor must they reveal any details about their technology. But they must report any accidents or instances when drivers had to unexpectedly turn off the autonomous technology within 10 days to the state's DMV.

Why did Uber launch the self-driving in pilot in San Francisco if it knew it was in violation of the law? A likely scenario was that Uber didn’t want to disclose its disengagement rate — the number of times the vehicle forced the human driver to take control because it couldn’t safely navigate the conditions on the road — or any accidents to the DMV, and by extension the public. The company referred questions about the emails to comments made by Levandowski in a call with reporters last December.

Uber first made the DMV aware that it was testing its self-driving vehicles in San Francisco at a meeting on September 16th, 2016. Four days later, Business Insider published video of one of Uber’s self-driving Ford Fusions tooling down Market Street, and made note of the fact that the company had so far failed to receive regulatory approval to test its autonomous vehicles in California.

The next day, Brian Soublet, the DMV’s deputy counsel, sent an email to Levandowski. “As you know, an autonomous vehicle cannot be operated in autonomous mode on public streets without the manufacturer holding a permit issued by the department,” Soublet wrote September 21st. “Is the vehicle that Uber has in San Francisco being tested in autonomous mode on public streets?”

Levandowski told Soublet that according to their logs, the car featured in the article “was under manual control” and simply collecting mapping data for future testing. He added that Uber had no intention of signing up for the permit because Uber’s self-driving cars required a human monitor at all times, and thus did not fit the legal definition of an “autonomous vehicle.”

From the outset, Uber’s interpretation of California’s three-year-old law was pretty squishy

The law defines an autonomous vehicle “any vehicle equipped with technology that has the capability of operating or driving the vehicle without the active physical control or monitoring of a natural person.” Levandowski argued that Uber’s cars required a human being in the driver’s seat at all times. But the law hinges on the presence of autonomous technology, not the presence of a human driver.

Still, he attempted to strike a friendly tone with the DMV. “These types of articles and inquiries are why we want and welcome an open channel of communication with you,” he added.

Soublet emailed back a few minutes later, noting that the mere fact that there were “logs” to check suggested the car had an autonomous mode. “By the pictures we’ve seen, the vehicle fits the definition of an ‘autonomous vehicle’ because it is ‘equipped with autonomous technology that has been integrated into the vehicle,’” he wrote. “The better course is to apply for a testing permit to eliminate any confusion about the operation of that vehicle on public roads.”

In a lengthy email to Soublet on September 22nd, Levandowski explained that the multitude of sensors, cameras, and other equipment typically seen on highly advanced self-driving cars were actually just “cool safety technology (similar to Tesla autopilot and other [adaptive cruise control] and lane keeping vehicles on the road).” In other words, the technology may look similar to the technology you’d find on a Google self-driving car (too similar, Google would say), but its just typical safety features.

“Responding to your previous email, I politely disagree,” Levandowski wrote. “We are not an [autonomous vehicle] and getting a permit further reinforces the misperception that we are an AV.” He insisted that Uber’s self-driving cars would require human drivers for “a very long time,” and vowed to inform the DMV “before this changes.”

In a later email, Levandowski told Soublet bluntly, “We don’t do AV testing.” This directly contradicts The Verge’s own experience riding in the backseat of one of Uber’s self-driving SUVs in San Francisco prior to the public launch in December. In addition, Uber allowed reporters from dozens of publications, including The Verge, to get behind the driver’s seat in Pittsburgh and experience the technology firsthand.

“We don’t do AV testing.”

In both cases, the vehicle drove itself for long stretches of the trip, deftly handling intersections, bridges, and pedestrians without human intervention. There were times when a chime would sound, signaling the driver to take control. But other than that, the car was capable of operating “without the physical control or monitoring of a natural person,” as stipulated under the law.

The idea behind these public demonstrations was to prove that Uber’s self-driving vehicles were capable of handling dense urban environments, in anticipation of one day being capable of operating without a steering wheel, pedals, or even a human in the driver’s seat. Uber CEO Travis Kalanick has described his company’s pursuit of autonomous technology as an existential threat. “If we are not tied for first, then the person who is in first, or the entity that's in first, then rolls out a ride-sharing network that is far cheaper or far higher-quality than Uber's, then Uber is no longer a thing,” he told Business Insider last year.

Dozens of companies from Detroit to Silicon Valley, are pursuing autonomous driving tech, but none have been so bold about it as Uber. As evidenced by the Waymo lawsuit and emails with the California DMV, the ride-hail company was willing to cut corners, split hairs, and obfuscate in its race to be the first to demonstrate the viability of self-driving cars. For Uber, being first was more important than being compliant.

A few days after it launched its unauthorized experiment in San Francisco, a self-driving Uber was caught on video running a red light. Uber claimed the car was under manual control at the time. “These incidents were due to human error,” a spokesperson told The Verge.

But that turned out to be false: the car had actually driven itself through the light, sources told to The New York Times. In fact, Uber’s self-driving cars failed to recognize five other traffic lights around the city. Had it signed up for the permit, Uber would have had to report that infraction to the DMV.