Silicon Valley behemoth Uber is no stranger to court battles. Still, this week saw the tech giant face one of its biggest courtroom confrontations yet: Trying to convince a judge to block a lawsuit from proceeding to class-action status.

On Thursday, the company with a whopping $51 billion valuation, went before US District Judge Edward Chen for a hearing in which the judge pondered whether he would grant class-action status to the suit, which seeks mileage and tip reimbursement for 160,000 Uber drivers in California.

The hearing comes as on-demand companies like Uber, Lyft and Postmates surge in popularity and reach, creating a vast pool of cheap, flexible labor. According to the nonprofit Freelancers Union, 53 million Americans now work as freelance contractors. That's about one in three US workers. The American Action Forum says independent contractors account for nearly 29 percent of all jobs added between 2010 and 2014. And the so-called 1099 economy already appears to be emerging as a key issue in the upcoming 2016 presidential campaign.

But even as on-demand companies move into the mainstream, critics are calling for broader protections of workers, who as independent contractors do not receive benefits like Social Security, Medicare, and workers’ compensation and cannot unionize. A slew of complaints about the loss of such benefits has rocked the industry and could threaten the entire business model of the on-demand economy.

In June, the California Labor Commission ruled that a San Francisco-based Uber driver should be considered an employee and should receive compensation for mileage and other expenses. (The decision, which Uber is appealing, does not carry the force of court precedent.) In what could be considered pre-emptive moves, some companies, including Instacart, Luxe, and Shyp have announced plans to convert some or all employees to part- or full-time status. Just this week, food-delivery startup Sprig joined them, and company CEO Gagan Biyani said the lawsuits facing other on-demand companies were a factor in the decision.

Of these suits, the one facing Uber is the furthest along. It could be weeks before Chen issues a decision on whether to elevate the suit to class action status. Should he do so, the suit could involve the largest number of plaintiffs against an on-demand company so far.

The Court Hearing

Uber's lead counsel, Ted Boutrous, has been down this road before. Four years ago, he went before the Supreme Court and had class action status overturned in Walmart v. Dukes. On Thursday, he told Chen lumping the issues of hundreds of thousands of drivers into a single suit would be ill-advised because there is no such thing as a typical Uber driver. Beyond that, he argued, converting Uber drivers to employee would threaten the flexibility and independence drivers enjoy, because the suit would challenge the company’s business model.

Shannon Liss-Riordan wasn't buying it. She's representing Uber drivers and has filed similar cases against Lyft, Caviar, Postmates and Homejoy, the latter of which has shut down in large part because of labor suits filed against the company. She told Chen that the question of whether Uber drivers prefer to be employees or contractors is legally irrelevant. Moreover, wage laws exist not only to protect workers, but to provide a check against businesses undercutting the competition to gain an unfair competitive advantage. (According to the National Employment Law Project, businesses stand to save up to 30 percent of payroll tax costs by classifying workers as independent contractors.)

Early in the hearing, Chen questioned whether making Uber drivers employees really would cost them some flexibility. “A lot of folks might think, ‘Suddenly, I’m an employee and I’m going to be called in at 8 a.m. and told to get down here,’” Chen said. “That might be a false assumption.”

He seemed skeptical of Uber’s arguments. “How can you argue that [every Uber driver] is an independent contractor, it’s clear, and yet there are individual variables here that preclude class certification?” he asked Boutrous.

Chen already ruled in March that the suit could move to jury trial, which is where the merits of the case would be debated—such as who has the right of control, drivers or the company. But in court, Chen noted certain commonalities among those issues of control, which seemed to suggest an inclination to certify the class. Chen said monitoring driver performance using Uber’s star rating system and controlling fares seemed very much within Uber’s control, not to mention Uber’s right to terminate a driver with sole discretion and without cause. But he did note some issues that did not seem to be in Uber’s control, such as routes and schedules.

Liss-Riordan pressed those uniform issues of control, arguing the suit could be stronger than a case in which FedEx recently agreed to a $228 million settlement compensating some 2,000 delivery drivers deemed employees, not contractors. That's because of Uber’s constant monitoring from its star-rating system.

But Boutrous pushed back, saying the fact its drivers could work for any on-demand company they choose once they are on the road. He argued that drivers aren't compelled by a duty or loyalty to Uber, and compared them to journalism freelancers. “Suppose a journalist worked for both the San Francisco Chronicle and the Los Angeles Times and gets a great story,” he mused in court. “With duty of loyalty, how does that journalist pick a publication?”

Boutrous also cited the company’s 17 agreements for drivers—calling them “licensing agreements with an app,” not employee contracts—as evidence that the group is so fractious the suit should not be certified as a class. The agreements evolved as Uber revised its terms over time at the discretion of teams in different cities, and Boutrous argued that they differ in substantial ways. "We have UberX, Uber Black, we have great variability," he said.

The two sides couldn't even agree on when the judge should consider making the suit a class action—a decision that could be reversed later, as was the case in Walmart v. Dukes.

“Let’s just first have a trial, instead of certifying a class,” pleaded Uber’s Boutrous.

“Uber could file a motion for decertification,” Liss-Riordan countered. She told Chen, “You could make the decision before the ultimate decision is decided.”

In the end, Chen punted, deciding not to rule from the bench. He'll make a decision in the weeks to come, but even he concedes someone may likely second-guess it. “I intend to go forward on this and rule and throw the dice," he said. "The chances are a higher court will have a look at whatever I do."