Ridesharing in Philadelphia is like a soap opera with unexpected twists and turns. At least, the latest episode provides good news for innovation.

At the end of September, Uber and Lyft found themselves back on the wrong side of the law after a temporary agreement permitting them to operate during the Democratic National Convention and beyond expired. The legislature failed to act relegating the ridesharing companies back to illegal status.

Then late last week, a Common Pleas Court Judge, Linda Carpenter, ordered that Uber and Lyft cease and desist operating in the city to the delight of cab companies. The cease-and-desist injunction was issued in response to a lawsuit filed by taxi drivers against the Philadelphia Parking Authority (PPA), the local agency that claims jurisdiction over all transportation companies. They claimed that the PPA was failing to provide equal protection to all drivers. In short, if they were regulated up to their necks, so should Uber and Lyft.

As we’ve reported, part of the short-term deal to keep ridesharing on the road included a 1-percent tax on all rides with 33 cents going to the PPA as hush money, and the rest to local schools.

Both companies maintained that they would continue to operate – even if it meant doing so illegally – because the market demands their services:

“While our appeal is pending at the Commonwealth Court, Uber will remain available for riders and drivers,” Craig Ewer, an Uber spokesman, said in a statement. “This situation makes it clear that Harrisburg needs to act: Pennsylvania must have permanent, statewide ridesharing legislation as soon as possible.”

Lyft noted to a tech news outlet:

"We are appealing the order and will continue operating in Philadelphia as the legal process moves forward. People in Pennsylvania want access to ridesharing, and we remain committed to finding a statewide solution that keeps this modern option available across the state."

Their defiance paid off when one day later, another judge, Robert Simpson, issued a preliminary injunction to stay Judge Carpenter’s order. The companies can operate legally once again.

The Pennsylvania legislature is expected to vote on statewide legislation authorizing ridesharing next week. However, for the past week, these companies have had to operate in a legal limbo.

The dueling orders and turmoil over ridesharing highlights the growing tensions states and cities face as innovation is disrupting traditional and well-regulated industries in real time. Government agents race to catch up to the new products and services that a dynamic economy is generating. However, whatever regulations they dream up to wrangle new businesses into their defined boxes is often obsolete by the time they pass it, exposing the lack of flexibility that regulatory regimes impose. No bureaucrat can anticipate how innovation will develop and how the market will respond.

Meanwhile, companies that have traditionally enjoyed the benefits of well-lobbied for laws and regulations are seeing the earth shift beneath them. Those who are willing to adapt to compete fairly have a chance, but too often companies and organized labor would rather sue, protest, and lobby their legislators for more regulation on their new competition, than seek to get their regulations reduced and to innovate themselves.

In the end, consumers will choose the best services and no amount of cronyism will stop the best free-market solutions.