Image copyright Dan Kitwood

The two cabinet ministers responsible for social care were informed of plans for the so-called dementia tax just hours before it was announced in the Conservatives' election manifesto.

Communities Secretary Sajid Javid and Health Secretary Jeremy Hunt were told less than 24 hours before the launch.

Costs of residential and domiciliary care were to be taken from the estates of pensioners bar a final £100,000.

But it proved so controversial that the proposal was changed within four days.

Prime Minister Theresa May embarked on a hasty retreat after Tory candidates complained that the policy was hugely unpopular. She said that an unspecified cap, which she described as an "absolute limit", would be imposed on care costs.

BBC Two's Newsnight has been told that Mr Hunt and Mr Javid were informed of the proposal for the manifesto at a late hour because future social care policy was being examined in the Cabinet Office rather than in their departments.

Ben Gummer, the then Cabinet Office minister who was co-author of the manifesto, was taking the lead in drawing up a Green Paper on social care due for publication later this year.

It is understood that the proposal to preserve a maximum of £100,000 in estates of pensioners who need residential and domiciliary social care had been examined in great detail ahead of the Green Paper. The cap was due to be included but was still being examined.

Cabinet ministers were consulted extensively in other areas of the manifesto. But ministers were only shown the whole document shortly before its launch in Halifax and 20 minutes before the media.

And the head of the prime minister's policy board during the election also told Newsnight that he was not even shown a draft of the manifesto.

Media playback is unsupported on your device Media caption "This was a catastrophe of a campaign" - Conservative MP George Freeman

George Freeman, the MP for Mid Norfolk, said: "This was a catastrophe of a campaign and I wouldn't expect necessarily in a snap election it gets signed off by cabinet and it goes through a series of negotiations presumably and discussions.

"So I wouldn't expect to be holding the pen on the last draft. But I didn't see any draft. And I think there was a culture in the campaign of 'we the five or six of us are going to do this'."

Members of Theresa May's inner circle feel deeply bruised by the fallout over the manifesto. Tory sources say that the prime minister was motivated by fairness on social care, asking why a 30-year-old in the north should subsidise the care needs of a pensioner living in a million pound house in the South East.