* Last minute deal saves oil traders painful write-downs
* State-oil firm NNPC debt-ridden, mismanaged
* Nigeria won credit ratings upgrades late last year (Adds details, background)
LAGOS/GENEVA, Jan 7 (Reuters) - Nigerian state oil firm NNPC has obtained a $1.5 billion syndicated loan to help it pay debts to international fuel traders, a senior banking source with knowledge of the deal said on Monday.
The deal was struck at the end of last year and is seen as crucial to easing the burden on big commodity traders facing the prospect of painful multi-million dollar write-offs, oil trading sources told Reuters.
Had Nigeria defaulted on these loans it could have restricted the future borrowing capacity of Africa's second largest economy and would have worried credit agencies like Fitch and Standard and Poors, which recently upgraded Nigeria.
The loan, provided by several Nigerian and international banks and brokered by Standard Chartered, will be paid back over five and half years. The NNPC has put up 15,000 barrels per day of its oil production as collateral, the banking source said.
Standard Chartered and the NNPC declined requests for official comment.
The top African oil producer's NNPC owes major commodity trading houses, including Glencore and Mercuria, around $3.5 billion in unpaid fuel supply bills, according to a report last year commissioned by the Nigerian oil ministry.
OPEC member Nigeria is among the world's top 10 crude oil exporters but has insufficient refining capacity to meet its domestic fuel needs and is heavily reliant on imports, on which it pays costly subsidies to keep a lid on retail petrol prices.
President Goodluck Jonathan attempted to end fuel subsidies in Nigeria a year ago but backed down after it sparked wide-spread protests against higher fuel costs.
Decades of mismanagement and corruption have left NNPC heavily indebted, several audits have shown.
A list of creditors published in an oil report earlier this year showed there were 35 firms still owed for fuel.
Trading companies have been battling for months to recoup the money and some have since stopped supplying Nigeria with fuels. But they have mostly remained in the west African country partly because of huge opportunities in the upstream sector.
The list showed that Glencore was owed $138 million, Vitol was owed $198 million and Trafigura was owed $53 million.
In reality, debts for some individual trading companies are widely thought to be much higher due to exposure via subsidiaries and partner firms.
For example, Bermuda corporate registration documents showed that Calson, owed $115.11 million by NNPC, was using Vitol's Geneva address. Similarly, Napoil, owed $75.6 million, is a partner of Trafigura, its website showed.
....Chijioke Ohuocha and Emma Farge
(Additional reporting and writing by Joe Brock; editing by Tim Cocks and James Jukwey)