Spending on the health service has doubled - so why is it facing the biggest deficit in NHS history? Where has all that money gone? And how can a cash-strapped hospital avoid going bust?

Like other hospitals around the country, it finished the last financial year with a massive deficit and now has to cut jobs and close wards. The National Health Service as a whole is an estimated £790m in the red, and the job losses across the country could mount up to 25,000. The Government is putting twice as much money into the NHS as was the case when it came to power - £76bn this year - but the deficit looks like being the highest in its history. So where has all the money gone?

The Royal Free is the most famous hospital to be hit by the crisis. Staff at the 12-storey tower block that overlooks Hampstead Heath were praised for their response to the bombings on 7 July last year, some of whose victims they treated. In the Heathside Coffee Bar - which offers no views of the heath, only pus-coloured walls, oppressively dim lighting and wicker chairs with the backs picked apart - there is still a poster asking anyone who saw anything that day to ring the Anti-Terrorist Hotline. One outpatient sipping coffee is reading the hospital's suggested list of questions they might like to ask their doctor - but as staff prepare to close wards, reapply for their own jobs or just move on, they have the right to ask them about their hospital.

What is wrong?

The simple answer to the first question is that the Royal Free must slash £25m from its budget. That means leaving beds empty and cutting 480 jobs.

What caused it?

The Royal Free wants foundation status, which would give it more control over its own future, and that means clearing all outstanding debts by next year. It has already shaved off £10m but must now erase another £6m of debt this year. It also has to meet a government target and produce efficiency savings worth 2.5 per cent of its budget, which amounts to £9m. And the hospital needs to save another £10m in some costs to pay for irresistible rises in others, such as salaries, the cost of drugs and equipment.

How serious is it?

Very. The patient in the next bed is dying: across London, the Queen Elizabeth Hospital in Woolwich has declared itself insolvent, crippled by a £93m rebuilding programme. It could go bankrupt and close. Whether the Government will really allow that to happen is another matter, although ministers are playing hardball with hospitals just now. "They have got to sort their problems out," said the Chancellor, Gordon Brown. "There is more money going into the health service. It is our duty to have more value for money."

How common is it?

One in four trusts is struggling. The University Hospital of North Staffordshire in Stoke-on-Trent is to cut 1000 jobs to pay for a £17m deficit. The New Cross Hospital in Wolverhampton is axing 300 jobs to claw back debt of over £38m. Across the country vacant jobs are to go unfilled, wards and operating theatres to close and even some community hospitals to close.

Can it be cured?

The Royal Free says it will cut 480 jobs, but there will be no redundancies. This apparent miracle will be achieved by reducing the number of temporary staff hired by the hospital and not filling all jobs that become vacant. "Patient care and safety remain paramount and we will, of course, ensure that we maintain staffing levels to a safe level."

The wards are also being re-ordered to get patients out of hospital more quickly, including greater use of day care and round-the-clock facilities. A spokeswoman said: "There is good evidence that patients who do not require acute care recover better in their own homes, as long as adequate support is available."

So far 127 beds have been taken out of action, and another 84 will be soon. That amounts to seven wards, but some units such as Berry, which specialises in stroke victims, will be incorporated into others and still treat the same number of patients. However, one unhappy nurse there said: "The last thing people want to hear after they have had a stroke is that they are going to have to move."

The Royal Free was founded in 1828 to provide free hospital care for those who could not afford treatment elsewhere. It was allowed to call itself Royal as an accolade from Queen Victoria, for its work with cholera victims. A model in the lobby gives an indication of how clean and exciting the angular concrete building looked when it moved to the cramped site in Hampstead in the Seventies.

Now it is rain-streaked and tatty, as ugly as its spiritual sister, the Barbican. Building work around the entrance is a sign of an eight-year, £50m refurbishment. The views are great though: the brochure for private patients, whose suites occupy the top floor, promises that "all the rooms have amazing views on to Hampstead Heath or the beautiful landmarks around London".

The "highly qualified nurses" there will presumably include some of those who are believed to be quitting the NHS and joining the private sector rather than applying for their own jobs again.

The man who has to deal with this mess is Andrew Way, chief executive of the trust, who only joined last July. He was called before Camden councillors last Tuesday to explain what was going on, and reportedly told them the predicament was worse than he had been led to believe.

"When I was appointed, the deficit was known about but there was an assumption that there would be a bail-out," Mr Way said, according to the Camden New Journal. "It [then] became clear that I had been appointed to help with the finances and that there would be no bail-out. The Government said, 'There will be no more money.' Hospitals have been told, 'What you have got is what you've got.'"

So how did it come to this? The Secretary of State for Health, Patricia Hewitt, has blamed the crisis on bad management and inefficiency in a few trusts, but that is not the whole picture. The truth is that hospitals have had far less money to spend on meeting their targets than the headlines - and the Government - has suggested.

Take the financial year that has just ended. The total budget for hospitals and community health services was £49.8 bn, up £3.6bn on the previous year. The King's Fund, which offers independent analysis of health service spending, calculated that half the increase went on pay rises for doctors, nurses and other staff.

The rises are the result of new contracts for consultants and GPs and new pay deals for nurses and other staff. When Labour came to power eight years ago, the NHS had a shortage of both workers and morale, not least because the pay was dismal. Since then it is said that 200,000 new staff have been recruited. British nurses and consultants are now among the best-paid anywhere in Europe.

Another 37 per cent of the increase last year was taken up by the cost of new drugs and buildings. The cost of the drugs we take on the NHS is £8bn. This is 46 per cent higher than it was five years ago, partly because new, more expensive drugs have become available. There are also more hospitals, newer wards and more beds than before.

The result of all this was that last year hospitals only had £475m to spend on things like reducing waiting times. However they still had to meet the Government's ambitious targets: to cut lists and reduce waiting times for operations (ultimately to 18 weeks, by 2008) and to make sure everyone in Accident & Emergency is seen within four hours.

Rather than miss the targets and be punished for it, over the past few years hospitals and health trusts have run up debts, sometimes disguising them in the accounts, borrowing money from capital funds or from the coming year. They have now been told they can no longer do that.

The Government has changed the rules of accounting in the NHS. In the past, trusts that overspent could be bailed out with money from those that came in under budget. This was seen to reward failure and has been stopped. The job losses and ward closures are the after-shocks of this cultural change.

However, some experts believe it will bring about a long overdue restructuring in the service, with mergers and closures being an essential part of increasing efficiency. In areas including Surrey and Sussex, Kent and Lancashire there are hospitals in the wrong place to serve the population, or too of them many offering the same services.

Patricia Hewitt remains bullish. "Many of the so-called costs are actually going towards treating more people with drugs, paying for better drugs and modernising our hospitals," she said. "The extra money that we've put in to the NHS is delivering real improvements in services for patients."

Back at the Royal Free the evening shift is coming on duty: the doctors, nurses, cooks, cleaners, engineers and others that make this mini-city work through the night while London sleeps. Most have had to commute from outside the immediate area, with its millionaire rows.

At least they don't work in Stoke-on-Trent, where the loss of a thousand jobs from the 7,000 at the hospital will have a serious impact on the economy and life of the town. People there and across the country are entitled to ask one last question about the condition of their hospitals:

What are the chances of survival?

Reasonable, is the truthful answer - but in the short term, there is nothing to help the pain.