WÖRTH AM RHEIN, Germany—Felix Kauffmann grabs the top rung on the ladder and hoists himself up into the cab, slipping behind the wheel, and reaching forward to start the motor on the 40-ton rig.

There is no wheezing or coughing or knocking sounds of the tiny explosions as diesel fuel ignites, no black soot cloud belching out of the smokestack....

The Future of Everything covers the innovation and technology transforming the way we live, work and play, with monthly issues on education, money, cities and more. This month is Transportation, online starting Nov. 3 and in print Nov 10.

WÖRTH AM RHEIN, Germany— Felix Kauffmann grabs the top rung on the ladder and hoists himself up into the cab, slipping behind the wheel, and reaching forward to start the motor on the 40-ton rig.

There is no wheezing or coughing or knocking sounds of the tiny explosions as diesel fuel ignites, no black soot cloud belching out of the smokestack. There is also no need to wait for the rig to charge, no charging-station cord to unplug. Mr. Kauffmann, a vehicle software developer at Daimler Truck AG, presses the starter button. The electric motor begins to whir, drawing power from a hydrogen fuel cell, not a battery. In less than a minute the machine is cruising at 55 mph.

“To get the same performance, we’d have to have batteries on board that weigh at least several tons,” says Mr. Kauffmann.

The GenH2 Truck is the hydrogen fuel cell prototype of Daimler’s answer to one of the greatest challenges of the coming decade: how to clean up the business of hauling cargo along the world’s highways and byways.

It is hard to find anyone in the transport industry who doubts that the future of trucking is electric, given the regulatory pressure to cut emissions in transport. But as the prototypes of the vehicles that are likely to replace today’s diesel rigs begin to roll out, a new technology battleground is emerging: hydrogen fuel cell versus battery.

Like diesel tanks, hydrogen tanks can be filled quickly, minimizing time off the road. Batteries are heavy, and their range is still limited. Yet hydrogen requires significantly more energy to make, as well as networks of producers, transporters and filling stations that don’t exist today. Batteries are comparatively cheap, and charging infrastructure is more widely available and rolling out fast.

Some truck manufacturers like Daimler, which owns Freightliner in the U.S.; Toyota Motor Corp. ; Volvo AB and others are betting that the future of long-haul trucking is a fuel cell engine powered by hydrogen. Daimler and Volvo operate a joint venture that makes fuel cells.

But others, such as Volkswagen AG’s truck unit Traton SE, which owns the Scania, MAN and Navistar brands, are putting their chips on batteries, believing that in the coming decade battery technology is going to advance so much that it will become the powertrain of choice for trucks from delivery vans to powerful semis. Scania says that, within a few years, it will launch a battery-electric truck that can pull 40 tons of freight for 4½ hours and fast charge during the driver’s mandatory 45-minute break.

There is no clear-cut choice right now which technology will be better. A lot will play out over the next three to five years.

— Art Vallely, president of Penske Truck Leasing

The discussion is reminiscent of past technology battles, like the competition between Betamax and VHS for dominance of the video market, a battle that Sony’s Betamax, considered by many the superior technology, lost to a rival that was cheaper and easier to use.

Even if hydrogen ends up being the better technology, it may ultimately have difficulty carving out a market if it takes too long to develop and battery technology keeps getting better. Batteries may end up being the technology that isn’t perfect, but good enough.

“Right now we’re at a point where there is a need to explore both because it’s not obvious,” says Stephanie Brinley, an automotive analyst at IHS Markit, a research group. “Hydrogen has been the next-story solution for 20 years. It may ultimately always be the next-story solution.”

Art Vallely, president of Penske Truck Leasing, which maintains a fleet of more than 350,000 commercial vehicles, says the industry is currently in a testing phase. Trucking companies have been testing battery electric vehicles in short-haul scenarios for the past few years, but haven’t yet been able to test fuel cell trucks because they are only now becoming available as prototypes.

“There is no clear-cut choice right now which technology will be better,” he says. “A lot will play out over the next three to five years.”

Both technologies have benefits and drawbacks, including their own infrastructure requirements.

Batteries for electric trucks, like their passenger car cousins, need to be periodically plugged in and charged. The energy stored in the battery powers the electric motor. Batteries have improved immensely over the past decade, but they still offer limited range on a single charge, and it still takes a long time to charge a battery. Fast-charging stations are also few and far between. But there are battery electric medium-heavy and light delivery trucks available today, which gives the battery a head start.

Hydrogen fuel cells create electricity via a chemical reaction between hydrogen, which is stored in tanks just like diesel, and oxygen. The electricity generated by the fuel cell powers the electric motor in the truck. The hydrogen tanks can be refilled, just like cars and trucks fill up at the pump today. But today there are only a handful of hydrogen filling stations in the U.S. and Europe, and there are no production and distribution networks ready for industrial scale consumption.

Producing hydrogen now is such an energy-intensive process that it cancels out any climate benefits from a zero-emission vehicle, analysts say. That is why vehicle manufacturers are counting on so-called green hydrogen, the production of hydrogen using renewable energy sources such as hydroelectric or solar power.

The use of hydrogen fuel cells in the biggest semi tractor-trailer trucks will lag behind battery electric trucks for up to a decade, says Greg Genette, senior research analyst in the U.S. commercial vehicle group at IHS Markit. By 2030, battery electric trucks will make up around 14% of U.S. new truck sales, compared with just 1% for hydrogen fuel cell vehicles, he says.

Daimler says it will make vehicles available to customers for testing in 2023. But it will take years for governments, hydrogen producers and others to build the needed infrastructure.

Truck makers and energy companies are beginning to invest in it. In October, Daimler and energy group BP PLC said that together they would build hydrogen infrastructure, including up to 25 hydrogen refueling stations in the United Kingdom by 2030.

“In the end, it won’t be the products that are missing but rather the infrastructure,” says Martin Daum, the CEO of Daimler Truck.

The cost of hydrogen is also prohibitive, though manufacturers betting on it say the price will come down in the coming years. For fuel cell trucks to be competitive, the price per kilo of green hydrogen has to come down to about EUR4 ($4.61) from around EUR8 today, Daimler says.

SHARE YOUR THOUGHTS

Do you think it’s more likely that electric trucks will run on batteries or hydrogen? Why? Join the conversation below.

Mr. Daum is convinced that once all of the pieces come together fuel cell trucks will become the better proposition for long-haul trucks because they will be more convenient to operate and run longer because of the short time to refill the tanks.

Andreas Kammel, head of alternative drives and autonomous driving strategy at Traton, says continuing improvements in batteries will likely ensure that batteries stay a step ahead of hydrogen. Battery systems will achieve cost parity with diesel in the mid-2020s, 10 years before hydrogen, he says.

“Batteries have a significant advantage and that advantage is here to stay,” he says. “Whatever is cheaper is going to win in the end.”

Some fleet operators believe that both technologies will be used but for different purposes.

Schneider National Inc., a trucking company based in Green Bay, Wis., is getting ready to deploy 50 battery electric Freightliner eCascadia trucks in southern California next year on intermodal routes, the trucks that pick up containers from ships for further transport.

Although hydrogen lags behind battery technology in development, Rob Reich, the company’s executive vice president and chief administrative officer, says unless batteries improve significantly, hydrogen fuel cells could eventually work better for long-haul routes of 500 miles or more.

“From what we’ve seen so far, battery electric trucks long-term have limited range, and are likely in the shorter and regional haul applications,” he says. “Fuel cell trucks are a better zero-emissions solution in medium and longer haul.”

Is he convinced the market will develop this way? “Convinced is probably too strong a word,” he says. “We had a great experience with one battery electric truck this year. We’ll take the opportunity to test a fuel-cell truck next year or year after.”

Write to William Boston at william.boston@wsj.com