SAO PAULO (Reuters) - OSX Brasil SA (>> OSX BRASIL SA), the struggling shipbuilder controlled by former Brazilian billionaire Eike Batista, got a much-needed lifeline on Tuesday after two banks agreed to refinance a 400 million real ($175 million) loan 17 days after it had come due.

State-run Caixa Econômica Federal and Banco Santander Brasil SA (>> Banco Santander Brasil SA), the lender that provided a guarantee to make the loan feasible, agreed on Tuesday to roll over the credit line for an additional 12 months, two sources with direct knowledge of the transaction told Reuters. The original loan had an 18-month maturity.

Shares of OSX jumped on the news. The stock reversed early losses and soared as much as 23 percent to 0.65 reais - OSX's biggest jump in more than three weeks. OSX has shed 95 percent of its value so far this year.

The refinancing comes less than a week after Batista's oil producer, OGX Petróleo e Gas Participações SA (>> OGX Petroleo e Gas Participacoes SA), filed for bankruptcy protection and improves the odds that OSX can avoid the same fate. Nearly all OSX business involves building or leasing vessels for OGX, which is not producing enough oil and gas to pay for them.

The crisis of investor confidence in Batista's industrial empire pushed Batista off his perch as the world's seventh-richest man and led to a struggle between shareholders, banks and bondholders over remaining assets. His unraveling has become a symbol of Brazil's economic woes after a decade-long boom made it one of the world's hottest emerging economies.

The Rio de Janeiro-based shipbuilder had debts of 5.3 billion reais as of June, with about 1.1 billion reais of that amount coming from Caixa, Brazil's largest mortgage lender. OSX has been racing to refinance those debts in recent weeks as it considered whether to file for bankruptcy protection as well, according to four sources familiar with the negotiations.

Santander Brasil agreed to put forward 100 percent of the guarantee for the loan, one of the former sources said. Both sources, who declined to be identified in order to comply with local banking secrecy rules, said talks between OSX and banks took longer than expected because the lenders wanted more collateral from OSX to seal the deal.

Caixa and Santander Brasil did not have an immediate comment on the loan refinancing. OSX could not confirm the information.

BONDS RISE

The price on OSX's 9.25 percent secured bond due on March 2015 gained 1 cent on the dollar to 81 cents on Tuesday.

In addition, bank executives were especially worried that the interdependence between OSX and OGX would make the former more vulnerable during the latter's bankruptcy protection process, one of the sources said.

Like other companies in Batista's EBX Group, OSX's troubles stem from the failure of OGX to meet any of its ambitious oil production targets. After starting output at its first field in early 2012, OGX repeatedly missed goals despite reassuring investors that copious amounts of oil would soon flow.

OSX, whose assets include an unfinished shipyard on the northern coast of Rio de Janeiro state, is one of OGX's biggest creditors. OGX owes OSX at least 2.45 billion reais, according to documents filed with the bankruptcy court.

In recent weeks, OSX has speed up the refinancing of other loans to stay afloat. Last month, the shipbuilder won a refinancing of a loan worth 518 million reais from state development bank BNDES for an undisclosed period.

Batista's personal fortune, meanwhile, has been nearly wiped out. Once valued at about $34 billion, enough to make him the world's seventh-richest man, the 56-year-old former powerboat racer is worth less than $1 billion today.

With most of his wealth gone, Batista could no longer borrow the large sums he had used to keep his companies, nearly all start-ups with little or no revenue, afloat until production began in earnest.

($1 = 2.28 Brazilian reais)

(Editing by Todd Benson, Krista Hughes and Bernard Orr)

By Guillermo Parra-Bernal