The UK will seek permission from a court on Tuesday to crack open a £400m piggy bank that is the legacy of a 90-year-old patriotic gift aimed at eradicating the national debt.

Since an anonymous donor gave £500,000 to pay off the British government’s debt in 1928, the money has been held in a trust fund and reinvested, awaiting the time when it would be large enough to eliminate Britain’s total borrowing.

That moment has not come to pass but Jeremy Wright, the attorney-general, will ask the High Court in London to release the £400m and let the government use the money at least to lower the amount of debt outstanding.

“Almost 90 years ago an anonymous donor bequeathed money to the nation and yet we have not been able to put it to good use,” said Mr Wright.

The £500,000 donation made in 1928 came with the express instruction that it was to be used to pay off the UK’s entire national debt. As total government borrowing came to £7.6bn at the time, the donation was not anywhere large enough to pay off the outstanding balance.

The value of the fund’s assets has grown to £400m, but Britain’s national debt has also swelled, to £1.6tn.

The attorney-general’s office estimated the fund had never grown above 0.066 per cent of Britain’s total borrowing. However, the fund has become one of the UK’s richest charities. The trustee is at present Zedra Fiduciary Services, according to the fund’s most recent accounts.

“We have been working with the Treasury, trustees and the Charity Commission to find a solution consistent with the donor’s original objectives of extinguishing the national debt,” said Mr Wright.

Barclays, a previous fund trustee, said in 2013 that it had been trying for four years to win permission to use the money to make charitable grants or at least turn it over to the Treasury.

The £500,000 donation was one of many made to the government after Stanley Baldwin, the then financial secretary to the Treasury, called for money from the rich to help pay off the UK’s debt, much of which was run up during the first world war.

While the cash value of Britain’s debt has increased substantially since the £500,000 donation was made, total borrowing as a proportion of national income has fallen from 165 per cent in 1928 to 88 per cent in 2017.