NHS patients who smoke or are obese are being told they must "heal themselves" before being granted access to surgery, in a dramatic extension of NHS rationing as doctors struggle to find £20 billion of savings over the next four years.

Doctors from 50 GP practices in Hertfordshire providing care to 450,000 patients have agreed to block those who smoke or have a BMI of more than 30 from being referred for routine hip or knee replacement surgery, without first being referred to a weight management or smoking cessation scheme.

The restriction, introduced eight weeks ago, is to be extended to all routine surgery over the next few months. Similar moves to ration care are being debated by family doctors across the country, in fulfilment of Health Secretary Andrew Lansley's plan to move the bulk of the NHS budget from managers, who don't spend resources, to GPs, who do.

But critics of the move say GPs must act as advocates for their patients, not as rationers of NHS services, and that the confusion of the two roles under the NHS reforms will undermine patients' trust. They say each patient must be treated according to their needs and a blanket restriction imposed on the basis of lifestyle is "unethical".

The ban on smokers and the obese in Hertfordshire is not absolute and patients who refuse to make efforts to give up cigarettes or lose weight will not be banned from having surgery. But instead of referring these patients directly to hospital, GPs will first discuss the added risks of their behaviour with them and recommend solutions.

Tony Kostick, chair of the north east Hertfordshire clinical commissioning group, said: "This is about GPs accepting a greater gatekeeping role. The NHS spends a fortune on treatments of limited clinical value. We trawled through the evidence and found outcomes were poorer for smokers and the obese. They are in hospital longer, have more complications, more post-operative infections and do less well."

He continued: "We are trying to get GPs to understand that if we spend money on one patient, that money is not available to spend on the next. If an obese patient loses weight they may not need surgery. We are not saying no to anybody but there are things you can do for yourself which will make you healthier before you have treatment. That is rationing but on the basis of the best clinical practice."

Mike Ingram, chair of the Red House GP Consortium in Radlett, Hertfordshire, which covers 18,900 patients, said: "This is discrimination against patients who may need care. People are complex – we do not support a blanket restriction solely on the grounds of smoking or obesity. That is unethical. Extending the restriction to all routine surgery is extremely destructive and unreasonable."

The British Medical Association said every patient should be considered on an individual basis and it "would not support a blanket ban".