The Conservative and Liberal Democrat parties were forced to give up hundreds of thousands of pounds of campaign funding Wednesday after it emerged that the elderly spinster who made the donation wanted it to go to the taxpayer.

Joan Edwards, a former nurse who died last September aged 90, apparently left ??520,000 in her will to "whichever government is in office at the date of my death".

But rather than going into government coffers, the money was channelled to Prime Minister David Cameron's Conservatives and their junior coalition partners, the Liberal Democrats.

Both parties said they accepted the money after Edwards' solicitors told them they were beneficiaries of her will, without knowing the full details. The Tories received ??420,000 and the Lib Dems ??100,000.

But in an embarrassing move for the coalition, both parties were forced to announce that they would give the money to the Treasury after a chorus of protest led by the opposition Labour party, who branded the situation "dodgy as hell".

Twitter users took to the website to propose better uses for Edwards' bequest than political campaigning. Using the hashtag #joanshalfmillion, suggestions ranged from investment in a maternity ward to supplies for a food bank for the poor.

Labour MP Ian Austin had posted on Twitter: "This is shocking. The lady obviously didn't intend her money to go to political parties, Do the decent thing!"

The bequest was revealed in figures released by the Electoral Commission on Tuesday.

Party officials had said the money was left to "whichever party was in government" at the time of Edwards' death, but a copy of her will, obtained by the Daily Mail newspaper, raised doubts that her wishes had been followed accurately.