The PM said such a pact would be the “worst outcome” of May’s election.
“You cannot let the people who want to break up our country into the government of our country,” he said.
Earlier, ex-Tory chairman Lord Baker said a Tory-Labour coalition could be needed after the election to keep the SNP from holding the balance of power.
Opinion polls have suggested that the election could result in a hung parliament with no single party winning an overall majority, leading to speculation about possible coalitions, while polls in Scotland suggest the SNP could take almost all of Labour’s 41 seats.
Speaking at an event to mark two months until polling day, Mr Cameron said: “If you thought the worst outcome in this election is a Labour government led by Ed Miliband, think again.
“You could end up with a Labour government led by Ed Miliband, propped up by Alex Salmond and the Scottish National Party.
“You could end up with an alliance between the people who want to bankrupt Britain and the people who want to break up Britain.
“Even today, Ed Miliband will not rule out a deal or backing from the SNP. If he cares about this country, he should do so.”
Mr Miliband told party members in Edinburgh that if the Scottish electorate voted SNP they risked handing power to the Tories, as “every one less Labour MP” made it more likely the Conservatives would be the largest part..
He did not address what might happen in the event of a hung parliament after the election in 60 days’ time, although he earlier told that a coalition deal with the SNP was “not on the agenda”.
And on Friday he said a coalition with the Conservatives was “not going to happen”.
“We are working for a majority Labour government,” he said. “I think we will leave those kind of grand coalitions to other countries.”
The former chairman of the Conservative party, Lord Baker of Dorking, had earlier said a Labour minority government reliant on the SNP in votes on critical issues would be a “nightmare” situation at Westminster.
Lord Baker said the SNP could then demand in return “even more levels of devolution”.
“That would lead more to the break-up of the United Kingdom. I think it would be a considerable threat.”
There could be a joint government of the Labour and Conservative parties instead, he said, in order to preserve the unity of the UK.
The SNP has ruled out going into partnership with the Conservatives
The peer’s words echo former Prime Minister Sir John Major’s warning that the SNP would enter any deal with Labour with the “overriding aim” of “prising apart” the union.
SNP leader Nicola Sturgeon has ruled out supporting a Conservative government and said it was “unlikely” the SNP would enter a formal coalition with Labour should there be a hung parliament.
However, she has indicated her MPs could work with Labour on an “issue-by-issue basis”.
Scottish Labour leader Jim Murphy has dismissed the idea of a grand coalition with the Tories as “ludicrous” and a “no-brainer”.
Mr Murphy told BBC Scotland he was “absolutely” ruling out Lord Baker’s idea, adding: “I don’t need lessons from Tory dinosaurs about how to run Scotland.”