David Cameron has been told that he can stay in Downing Street even if he loses the election while other parties try to piece together a coalition. He will remain Prime Minister until an alternative is found, and ministers who lose their seats could continue to serve in a caretaker government for weeks. Sir Jeremy Heywood, the country's top civil servant, insisted that Mr Cameron must remain in Number 10 until there can be a 'smooth transition' to a new government. David Cameron will remain Prime Minister until an alternative is found, and ministers who lose their seats could continue to serve in a caretaker government for weeks . In 2010, Gordon Brown was accused of 'squatting' in Downing Street while the Tories and Lib Dems negotiated the details of their coalition pact. But Sir Jeremy, the Cabinet Secretary, insisted that it was the right thing to do to ensure the wheels of government kept turning. Five years ago the coalition deal was agreed in just five days, but with a hung parliament likely again, it is expected that any power-sharing agreement could take much longer, possibly even several weeks. Sir Jeremy told the Political and Constitutional Reform Committee: 'The reality is what Gordon Brown did last time I think was generally applauded, not in every single quarter. 'But the idea that you would stay in Downing Street until it was pretty clear who would be better placed than you to form another government, that's what he did, that's what happened and we ended up with a very smooth transition. 'I would certainly urge a future prime minister in the same position to adopt a similar approach.' Sir Jeremy Heywood, the country's top civil servant, insisted that Mr Cameron must remain in Number 10 until there can be a 'smooth transition' to a new government . Polls suggest both Labour and the Tories will fall short of securing an overall majority at the general election on May 7. With the SNP on the rise in Scotland, the Lib Dems defending 57 seats and Ukip predicting they will win more than 10 seats, it is possible that no two parties would be able to form a majority. A coalition deal between three or more parties would take much longer to agree, and could prove unstable. Sir Jeremy added: 'I think it would be very unfair, particularly if it took slightly longer next time than just the five days it took last time, it would be very unfair if the incumbent prime minister was criticised for staying around in Downing Street when he was simply doing what most people would regard as the expectation placed upon him.' In 2010, Gordon Brown was accused of 'squatting' in Downing Street while the Tories and Lib Dems negotiated the details of their coalition pact . Sir Jeremy said it would be a 'bad mistake to drag' the Queen into any decisions or negotiations that would need to be taken if no party has a clear majority after the election, even if there if two coalitions were formed of equal numbers, telling the committee it was a decision for politicians. Asked if the ministers who have been kicked out by voters would be able to remain part of a caretaker government, he replied: 'Yes, they can'. Sir Jeremy told the committee he has talked to David Cameron about the role of the civil service during any coalition negotiations after May 7. 'I have discussed it with the Prime Minister and he is agreed in principle that the civil service should play the same role in 2015, if it is needed, as was played in 2010 but we haven't yet got into any detail,' he said. Labour, the Conservatives and the Liberal Democrats have all introduced new processes since the last election to take factor in the possibility of a hung parliament.
Top civil servant Sir Jeremy Heywood reveals post-election planning . Cabinet Secretary has spoken to Cameron about staying on after result . He will remain PM until an alternative government can be formed . Coalition talks between multiple parties could last for several weeks . Ministers who lose their seats could stay on in caretaker government .