Elon Musk has managed to win a $50m bet by building the world's largest ever lithium-ion battery.

The billionaire chairman and chief executive of Tesla has delivered a renewable energy project for South Australia, building the world's largest ever lithium-ion battery.

Mr Musk and Lyndon Rive, the head of Tesla's battery division, proposed building an energy storage facility in the state following severe blackouts after a storm in March 2016.

At the time Musk made a bet, saying Tesla would get the battery installed and working within 100 days of the contract being signed or the $50m (£37m) system would be free.

This deadline was due to expire on 1 December, ahead of which state Premier Jay Weatherill has announced that the project had been completed.

The battery will store energy from a nearby wind farm run by the French renewable energy company Neoen.

"South Australia is set to have back-up power in place this summer through the world's largest lithium ion battery, which is set to be energised for the first time in the coming days as it enters a phase of regulatory testing," Mr Weatherill said.

Musk tweeted: "Congratulations to the Tesla crew and South Australian authorities who worked so hard to get this manufactured and installed in record time!"

As a maker of electric automobiles, Tesla has also invested heavily in energy storage and solar panel technology - and it believes its technology could develop far beyond vehicles and supply power to the grid.

The deal has seen Tesla manufacture a 129MWh battery in Jamestown, a town with a population of less than 1,500 people, just over 120 miles north of Adelaide.

"This is not a minor foray into the frontier," said Mr Musk at the time.

"I'm pretty darn impressed with South Australia willing to do a project of this magnitude that is beyond anything else in the world.

"That takes a lot of gumption," he added. "I do see this as something that the world will look at as an example."