The feeling of relief in the British car industry was almost palpable on Friday, when Jaguar Land Rover said it would invest billions in producing new electric vehicles in the UK. After the recent closure of two other UK automotive factories in five months – Honda in Swindon and Ford in Bridgend – JLR boss Ralf Speth was clearly pleased to have good news for the 2,500 workers at the Castle Bromwich plant.

Yet amid the congratulations, Speth also struck a note of warning. Not on Brexit this time, but on the future of the car sector in the absence of a British battery industry. “One thing is clear: if batteries go out of the UK, then also the automotive production will go out of the UK,” he said.

The combination of the Volkswagen diesel emissions cheating scandal, the entry of Tesla and imminent decarbonisation targets have set carmakers scrambling to make vehicles powered by lithium ion batteries.

BMW will this week launch its new electric Mini, to be manufactured in Oxford, and PSA Group said that if a no-deal Brexit was avoided, it would build its new Vauxhall Astra cars in Ellesmere Port, with electric versions expected to follow.

Where the batteries will be sourced remains to be seen. A new JLR facility in Hams Hall, between Coventry and Birmingham, will import battery cells from Asia to assemble into packs, while BMW will import packs from Germany.

The opportunity for a global industry enjoying explosive growth is enormous – and without a battery industry, the jobs of 114,000 workers making the UK’s combustion engines could disappear by 2040, the government-backed Faraday Institution warns.

By then the UK will need annual battery capacity of as much as 200 gigawatt hours (GWh) – 100 times more than current production – if it fully grasps the opportunity to make batteries for the UK’s 1.8m vehicles, the Faraday Institution forecasts. That would be equivalent to 13 of what Tesla founder Elon Musk labelled “gigafactories” – those capable of 15GWh a year or more.

The Advanced Propulsion Centre (APC), a Coventry-based scheme to direct £1bn in public and private investment in clean car tech, estimates that it will cost about the same to build a single proper gigafactory.

Ian Constance, a former senior manufacturing executive for Ford who heads the scheme, says he wants to “concertina the process” of creating a proper supply chain, allowing the UK to steal a march on rivals.

He has a mandate to preserve 30,000 British jobs by 2023 (as well as preventing 50m tonnes of CO 2 emissions), so he wants to pull as much of the battery value chain into the UK as he can. It would, Constance argues, make sense for a future British electric vehicle (EV) industry also to source its batteries from the UK.

“If you are going to make EVs in volume, shipping lots and lots of batteries from Asia is going to give you a very long, high-cost supply chain, which is going to have millions of pounds’ worth of stock on the water,” he said.

The UK has already missed one shot at having a world-leading battery industry. The lithium ion battery was invented at Oxford University in the late 1970s, but Japan’s Sony ended up commercialising the technology.

Facebook Twitter Pinterest Craig Jenkins, 24, PhD student; Oliver Isles, 19, battery apprentice; and Cherry Huang, 28, post doctorate researcher in batteries. Pictured at Warwick Manufacturing Group’s Energy Innovation Lab in Coventry. Photograph: Jonny Weeks/The Guardian

That was a “disaster” for the UK which must not be repeated, according to Mark Amor-Segan, chief engineer at the University of Warwick’s energy innovation centre, one of the key sites tinkering with battery chemical mixes and the arcana of welding to try to pack in the power.

Some battery factories already exist in the UK, but on a smaller scale. Packs for the Nissan Leaf are produced by AESC in Sunderland. Hyperbat, a joint venture between the Williams group of Formula One fame and component maker Unipart, has retooled an old car exhaust factory to produce low volumes of batteries for sports cars like the Aston Martin Rapide E and the Lotus Evija.

Paul McNamara, technical director at Williams Advanced Engineering, says gigafactories in the UK would really make sense only to supply UK production, meaning one of the big manufacturers would need to make a commitment to buy British.

“The danger we face in the UK is, even if a champion like JLR says we’re going to have electric, it’s not that difficult to import from other countries,” he says.

The threat to British jobs if big carmakers don’t commit has already been underlined this year, after Ford said last month it would close its combustion engine plant in Bridgend. Union representatives pushed for investment to upgrade the factory for new electric technologies, but Ford said it would only locate battery production near car plants.

“If we’re going to keep assembly operations here, then we need battery facilities,” said Steve Turner, assistant general secretary for manufacturing at the Unite union. “We’ve got to fight for future investment to make sure it stays in the UK.”

The scale of the challenge is daunting – China has already spent billions subsidising its electric vehicle industry and the German government has reportedly earmarked €1bn (£960m) to support a consortium looking to produce electric car battery cells.

Some in the industry are sceptical that investments in smaller projects in Britain will be enough, particularly given the uncertainty over Brexit. Yet the APC’s Constance is confident that a British battery industry will bloom – albeit with talks with potential gigafactory investors still months from conclusion.

“We need to have something here by the middle of next decade,” he says. “There’s so much potential demand in the market, but these things cost a lot of money.”