The prime minister made the promise of warship HMS Bulwark, two patrol boats and three helicopters at an emergency summit of EU leaders in Brussels.
An estimated 800 people died when their boats sank off Libya on Sunday.
"I think it is right for Britain to step forward," Mr Cameron said.
"It was a positive meeting because other countries are joining Britain in offering military assets in order that will help to save lives.
"But what's emerging is what we need which is a comprehensive plan, going after the criminal gangs, going after the traffickers, going after the owners of the boats, potentially taking action there as well."
He said the Royal Navy will be "saving lives, not offering people asylum in the UK" and they would take migrants to Italy "or to other nearby countries".
The European Union withdrew funding for Italy's "Mare Nostrum" search and rescue operation last year, replacing it with the smaller Operation Triton.
Following the crisis talks, European leaders are to triple funding for search and rescue operations in the Mediterranean to €9m (£6.5m).
The EU will also look at ways to capture and destroy smugglers' boats, officials said.
Earlier, funerals for 24 of the victims of Sunday's disaster were held in Malta.
In London, protestors gathered for a mass "die-in" in Parliament Square to advocate migrant rights.
"Protect people, not borders", "#dontletthemdrown" and "detention centres, shut them down" were among the messages on the protestors' placards.
David Cameron has said a "comprehensive plan" is needed to tackle migrant traffickers as he pledged military assets to boost search and rescue efforts in the Mediterranean.