At a reception, a television crew picked up a conversation between the Prime Minister and the Queen.
"We had a very successful cabinet meeting this morning talking about the anti-corruption summit ...," Cameron told Her Majesty. Then, with a bit of a chortle, he said, "We have got the leaders of some fantastically corrupt countries coming to Britain ... Nigeria and Afghanistan, possibly the two most corrupt countries in the world."
The Queen's response to these comments is not clearly audible, though the Archbishop of Canterbury, who was also part of the conversation, can be heard saying that the current Nigerian President is not corrupt.
Asked whether the Prime Minister was aware his remarks were being recorded, a Downing Street spokesman said there were multiple cameras in the room.
An anti-corruption summit opens in London on Thursday.
But the blogosphere didn't wait. It erupted Tuesday.
"On the face of it, it is perhaps one of the most undiplomatic things a prime minister could say -- to describe two countries as fantastically corrupt just hours before their leaders visit Britain," wrote the BBC
Both 'have acknowledged the scale of corruption'
It wasn't clear Tuesday whether Cameron regretted making the comments.
"We cannot comment on a conversation between the Prime Minister and the Queen," said a Downing Street spokesman in a statement emailed to CNN.
"Both President Buhari of Nigeria and President Ghani of Afghanistan have acknowledged the scale of the corruption challenge they face in their countries," the statement continues, referring to Muhammadu Buhari and Ashraf Ghani.
"In a collection of essays on the fight against corruption to be published on the day of the summit, President Ghani writes that Afghanistan is 'one of the most corrupt countries on earth' while President Buhari writes that corruption became a 'way of life' in his country under 'supposedly accountable democratic governments.'"
The statement says both leaders "have been invited to the summit because they are driving the fight against corruption in their countries. The UK stands shoulder to shoulder with them as they do so."
A 2015 report
by Transparency International, an independent anti-corruption group, scores Nigeria the world's 136th most corrupt country, out of 168. Afghanistan fares worse in the survey, coming in at number 166.
"There is no doubt that historically, Nigeria and Afghanistan have had very high levels of corruption, and that continues to this day," said Cobus de Swardt, managing director of Transparency International, in a statement
. "But the leaders of those countries have sent strong signals that they want things to change."
Nigeria was not pleased with Cameron's comments.
In an statement emailed to CNN, Nigerian presidential spokesman Garba Shehu said Cameron was looking at the past.
"This is embarrassing to us, to say the least, given the good work that the President is doing," the statement said. "The eyes of the world are on what is happening here. The Prime Minister must be looking at an old snapshot of Nigeria. Things are changing with corruption and everything else."
Buhari struck a less antagonistic tone in a statement Wednesday.
"I am not demanding an apology from anybody," he said. "I am demanding a return of assets."