Boris Johnson has told Conservative cabinet ministers who have been accused of positioning themselves for a post-Cameron leadership to "put a sock in it and back the prime minister".

Johnson did not mention by name the ministers he had in mind, but his remarks on Friday were likely to be seen as a slapdown to the home secretary, Theresa May, who last week fuelled speculation about her leadership ambitions with a speech that ranged far beyond her policy brief.

May is reported to have been the target of a warning by the education secretary, Michael Gove to Tory cabinet ministers in private earlier this week not to undermine David Cameron's position as PM.

Johnson, who is himself regarded as frontrunner in the succession race if he can find a seat in parliament, said speculation over a challenge to Cameron's leadership was "complete nonsense".

Speaking to the Sun, the mayor of London said: "If ministers are setting out their stall now, it strikes me as being very odd.

"They should save their breath and cool their porridge. Put a sock in it and get on and back the prime minister.

"David Cameron is doing a fantastic job. I am backing him. It's mid-term. People need some sort of political drama so they're inventing one. I think it's complete nonsense."

Johnson said he "very much doubts" Cameron's position was under threat.

And he added: "This is the right moment for everyone to support what the Conservative-led coalition is doing, particularly to make London even more competitive and produce a really lasting recovery.

"They should save their breath. Put their shoulders to the wheel, all hands to the mast, and all shoot from the same trench, to mix my metaphors."