LOS ANGELES—The nation’s busiest ports are emerging as a key battleground in the legal fight over whether truck drivers should be counted as employees or independent contractors.

Several trucking companies operating at the ports of Long Beach and Los Angeles have filed for bankruptcy protection in recent months, citing mounting costs to settle hundreds of legal claims. These operators haul containers from the docks to rail yards and freight depots, a key journey of just a few miles that allows major retailers and manufacturers to quickly move their imported goods to stores and factories across the country.

The bankruptcies in the trucking sector come as some higher-profile cases in the debate over employee status are paying out hefty settlements. Ride-hailing service Uber Technologies Inc. agreed to pay as much as $100 million to drivers last month, and delivery company FedEx Corp. reached a $228 million settlement last year. But in the $12 billion-a-year port-trucking business, known as drayage, where hundreds of small operators compete on thin margins, the cost to settle similar claims can be overwhelming, analysts say.

The turmoil raises questions about the future of short-haul trucking at the nation’s ports. Litigation with drivers and the higher cost of full-time labor could force drayage operators to charge more for their services or it could put them out of business entirely, reducing the overall number of carriers and raising costs for shippers, analysts say.

The trucking industry is bracing for the classification fight to spread to other ports. “As most things go in trucking...California leads the way,” said Curtis Whalen of the American Trucking Associations, an industry group. “Having this hanging over your head is obviously not good.”

Since 2011, 799 complaints have been filed against port-trucking companies with the California Labor Commissioner’s Office, alleging drivers were misclassified as independent contractors and denied the wages and benefits afforded to full-time employees. A total of more than $35 million has been awarded to drivers in those cases, according to the Labor Commissioner’s Office.

Over a dozen class-action lawsuits alleging misclassification at the port-trucking companies are pending in California courts. And the National Labor Relations Board recently filed a complaint against a California port-trucking company that is one of the first to include the allegation that drivers’ misclassification as independent contractors violates the National Labor Relations Act.

Some trucking companies say the drivers filing legal claims over misclassification amount to a relatively small number in the Southern California industry. “Most drivers aren’t looking to become employees,” said Weston LaBar, executive director of the Harbor Trucking Association, which represents trucking companies at the ports of Los Angeles and Long Beach.

Noel Perry, an economist with FTR Transportation Intelligence, a freight-market analysis firm, estimates that there are about 2,000 port-trucking companies nationally. Drayage companies tend to be small, running 100 trucks or fewer.

Publicly traded logistics company Hub Group Inc. recently closed its Southern California ports operation, a little over a year after converting the local fleet from independent contractors to full-time drivers, citing “unsustainable” costs.

“ Unless everybody else is forced to use the same [full-time] labor, these companies won’t be able to raise their prices to pay for it. ” — Noel Perry, an economist with FTR Transportation Intelligence

Last month Pacific 9 Transportation filed for bankruptcy protection, citing among its debts nearly $7 million it owes to drivers after losing several claims before the state labor commissioner. Premium Transportation Services Inc., one of the largest port-trucking businesses in Southern California, filed for bankruptcy protection in March, telling the court it couldn’t afford the costs of litigation with drivers. A handful of other port-trucking companies in California have made similar claims in bankruptcy filings in recent years, and some have shut down.

“Unless everybody else is forced to use the same [full-time] labor, these companies won’t be able to raise their prices to pay for it,” said FTR’s Mr. Perry.

As many as 25,000 drayage drivers, the vast majority of them independent, make the trek to and from port terminals in California every day. For many of them, their independent status means they can theoretically make more money than full-time employee drivers, depending on how many loads they carry each day.

Justice for Port Drivers, a campaign supported by the International Brotherhood of Teamsters, is organizing drayage drivers at ports around the country—most heavily in Southern California. The organizers say that trucking companies push their costs, such as fuel, insurance, maintenance and lease payments, onto the drivers. And they say they’re not compensated for many of the hours they work, such as the time spent waiting in line to pick up goods.

Drivers at drayage firms owned by XPO Logistics Inc. say they were improperly classified as contractors and are owed up to $200 million in unpaid wages. A handful attended the company’s annual shareholder meeting on Wednesday to voice their concerns.

“We have excellent relationships with our employees and the owner operators who serve our customers,” an XPO spokesman said on Tuesday.

The California Labor Commissioner’s Office last week began offering port-trucking companies “amnesty” from any penalties they’ve incurred for misclassifying drivers if they voluntarily make their drivers full-time employees and provide back pay. The state Department of Industrial Relations said Tuesday that no companies have applied for the program so far.

Jackie Mattare, president of trucking company Desert Express, said she has employed full-time drivers for 20 years and she thinks other operators should, too. If everyone faced the same employment costs, rates for drayage services wouldn’t be so low, Ms. Mattare said, “and the industry will become a safer and more viable place to work.”

—Loretta Chao contributed to this article.

Write to Erica E. Phillips at erica.phillips@wsj.com