Representatives of Britain's doctors have backed calls for hospitals to stop selling junk food anywhere on their premises, including in shops, cafes and vending machines.

Delegates at the British Medical Association's annual conference in Edinburgh overwhelmingly passed a motion urging hospitals to sell only healthy products, after a cardiologist and anti-obesity campaigner argued that it was obscene for places that promote health to also have fast-food outlets on site.

The 500 representatives endorsed the move, which was proposed by Dr Aseem Malhotra. They called for hospitals to ban all junk food and sugary drinks and for the BMA to lobby the Department of Health and the NHS Confederation, which represents hospitals, "to ensure that all NHS premises should clearly display the health risks involved with junk food and drinks, especially in kitchen areas and on vending machines."

The campaign is also supported by the Academy of Medical Royal Colleges, which represents all the UK's 220,000 doctors professionally. Prof Terence Stephenson, chair of the academy, said: "The academy is extremely pleased that the BMA supported the motion for a ban on junk food in hospitals. And we are keen to work with all interested parties in making this a reality."

Malhotra, a cardiologist at London's Royal Free hospital, told delegates: "It is appalling to observe on ward rounds patients, some of whom are not fully mobile, gorging on crisps, confectionery and sugary drinks – the very food items that may have contributed to their admissions in the first place.

"It is obscene that many hospitals continue to have high street fast-food franchises on site as well as corridors littered with vending machines selling junk food."

Only one delegate, Thomas Nixon from the BMA's junior doctors committee, spoke against the motion. He said that sometimes he might want to have a fizzy drink or a high-calorie snack after his shift. Nixon also asked whether the provision of a plate of biscuits when breaking bad news to relatives would be at risk, with bowls of fruit offered instead.

The NHS Confederation opposes the plan. Its director of policy, Dr Johnny Marshall, says that commercial outlets in hospitals are "highly valued" by patients, their families and hospital staff, and most sell healthy products as well as sweet treats. It is also unfair and unrealistic to deny patients the right to buy sweets to cheer themselves up, he argues.

Hospitals make little money from such franchises, according to Marshall. "There isn't a hospital trust in the country that would prioritise the relatively small amount of income they get from these sources above the overall health of their local community," he said.

The BMA conference also backed a call to campaign for a cut in the price of fruit and vegetables, in order to make them more affordable as part of a drive to encourage healthy eating, and for the government to extend initiatives involving free fruit and vegetables in schools to all primary-age children.

Currently pupils in England aged four to six are given a free portion of fruit or vegetables each school day.

A New York judge has struck down a ban on large fizzy drinks promoted by New York's mayor, Michael Bloomberg as a tool in the fight against obesity. The judge called the proposal 'arbitrary and capricious'. Would you support restrictions on sugary soft drinks?