Tesla Motors Inc. is expected to announce Friday a $1 billion loan commitment from GM to finance its $1-billion lease agreement with the California automaker.

The agreement, which will include leases for about 4 million Model S and X vehicles, comes as the two companies continue to battle a host of regulatory and legal battles.

GM is suing Tesla over a rule change that requires it to list cars sold by a manufacturer on its website, a move that could cost the automaker billions of dollars in lost revenue.

The deal, which is subject to approval by a U.S. judge, will be the largest in GM’s $50 billion capital spending program, the company said Friday in a filing with the Securities and Exchange Commission.

It will include $1,100 in financing, GM said.

The automaker, which has a $6 billion debt to equity ratio, expects the loan will help fund the lease payments for about 450,000 vehicles.GM said in a separate filing that it is looking to secure another $1 million from a bank to finance the loan.

That loan, it said, will help finance the purchase of approximately 6.5 million Model X vehicles from Tesla, as well as its ongoing investments in other Model S vehicles.