During a tour of a lamb and beef farm in North Wales, the prime minister said farmers could lose as much as £330m on lamb and beef exports alone if Britain were to withdraw from the EU.
Benefits of the single market outweigh frustrations with red tape, he said.
But farming minister and Leave supporter George Eustice said the UK could back farmers better than the EU.
'If we vote to leave the EU and take control, we will be able to design an agricultural policy that delivers for British farmers," said Mr Eustice, a former key political ally of Mr Cameron.
"We would replace our membership with a new UK-EU partnership, which would include a free trade agreement.
'We would be free to reduce the burden of regulations on British farmers.  We would spend as much, or more, than we do now on supporting farmers and the environment."
Mayor of London Boris Johnson also weighed in, branding the Common Agricultural Policy "demented" and in places "corrupt".
Big players on both sides of the argument have been making their case as to why people should vote to Leave or Remain in the 23 June referendum on the UK's EU membership.
On a visit to Denbighshire, during which he briefly cradled a new-born lamb, Mr Cameron said continued, unfettered access to the EU's internal market was vital to the region's farmers and food producers.
The Remain in EU campaign has claimed that more than 90% of UK lamb and beef exports - worth around £605 million - currently go to the EU - figures disputed by those backing EU exit.
Mr Cameron said the EU was not perfect but if farmers had to rely on World Trade Organization rules rather than EU membership, they could be faced with annual tariffs of up to 40% and additional costs of £240m for beef and £90m for lamb,
"Farmers are faced with bureaucracy, inspections, the payment system and it's very important we deal with those issues but there's a bigger issue which is a market of 500 million people who we can sell some of the best meat in the world to," he said.
Asked if there was a Plan B if the UK were to leave, he replied: "Of course we have to be ready, we have just produced a document on the alternatives."
Mr Cameron later told the Welsh Conservatives' Spring conference that any alternative trading arrangement with the EU, including one based on Canada's free trade agreement, which is being advocated by Mr Johnson, would result in "new impediments, restrictions and costs for Welsh businesses".
Dismissing Mr Johnson's case that the UK could retain the benefits of the single market without the downsides of EU membership, the PM said "if something sounds too good to be true, that's normally because it is".
Former environment secretary Owen Paterson, who is backing EU exit, has argued that Britain would be free to set its own subsidies and its own environment policies outside the EU.
He has said the "dotty idiocy" of EU directives had made flooding on British farmland worse.
Britain's farmers received £2.3bn in direct subsidies from the Common Agricultural Policy in 2015. The CAP takes up 39% of the EU's budget - about 23p a day for every EU citizen.
The National Farmers' Union has challenged both sides to provide more evidence of the benefits of staying or leaving, having commissioned its own research into the impact on farm-gate prices, farm incomes, commodities production and trade flows.
David Cameron has warned that British agriculture would suffer if the UK votes to leave the EU.