Prince William was briefed by service personnel during his visit
Prince William has made a secret visit to meet British troops in Afghanistan.
William, 25, spent three hours with UK service personnel at an airfield in Kandahar on Monday before flying home.
Clarence House said the trip, planned since 2007, was to familiarise William with RAF missions but publicist Max Clifford said it was a "PR exercise".
The prince flew back with the body of a soldier killed in action and privately met relatives of Trooper Robert Pearson, who died on 21 April.
Trooper Pearson was killed when his vehicle hit a mine.
Clarence House said William had been "honoured" to be a member of the air crew that repatriated Trooper Pearson's body.
It also said the Prince of Wales and the Queen had given their permission for the confidential trip, which had been a "success".
The prince, who received his RAF pilot's wings earlier this month, flew a military transport plane for part of the journey from the UK to Kandahar.
Wiliam flew in a C-17 Globemaster plane which left RAF Brize Norton, in Oxfordshire, on Sunday and reached Afghanistan the following day.
I think the cynics amongst us will say it's an attempt to cover up the Chinook jollies
Ken Wharfe Former royal protection officer
A Clarence House spokesman said: "The purpose of the trip was for the prince to familiarise himself with the operations of the RAF in theatre."
He said the whole trip had taken about 30 hours and "passed without a hitch".
After leaving Afghanistan, William, who is second in line to the throne, flew on to Al Udeid Air Base in Qatar.
Earlier this year, Prince William's younger brother Harry was serving on the front line in Afghanistan but his tour of duty was cut short after a media blackout broke down.
When details of his deployment leaked, it led to fears Harry would be targeted by the Taleban and he was returned to the UK having served for 10 weeks.
Prince William is coming towards the end of four months of training with the RAF, where he is known as Flying Officer Wales.
The attachment is designed to teach him about the force's ethos, military role and traditions and prepare him for the day when he is head of the armed forces.
Earlier this month, he was presented with his RAF pilot's wings by his father, Prince Charles, at a graduation ceremony.
In June, he will begin a new attachment with the Royal Navy.
Publicist Max Clifford said the Afghanistan trip had been "a good public relations exercise".
It follows recent criticism of Prince William when it emerged he had used a military helicopter to land near his girlfriend's home and to go to a stag do on the Isle of Wight.
The Ministry of Defence accepted there had been a degree of naivety in the planning of these flights.
Mr Clifford told BBC News the trip would get "some good headlines".
"It is a good public relations exercise for William, in view of the bad publicity last week where he was dropping in on Kate Middleton's family in an RAF helicopter.
"Bad week last week, good week now."
The background to Prince William's trip to Afghanistan
Former royal protection officer Ken Wharfe said William would have been in no real danger during his visit to the war zone.
He also thought the visit was a public relations exercise.
"I'm slightly sceptical about this. I think the cynics amongst us will say it's an attempt to cover up the Chinook jollies," he said.
Meanwhile, Andrew Bergin, of the Stop The War Coalition, branded the prince's trip a "shameful waste of public money".
He said: "It belittles the very real problems soldiers face in Afghanistan. The resources devoted to this trip would have been better spent providing decent equipment for the troops and aftercare for injured soldiers."
And he accused the MoD of "manipulating the media to try to cleanse the Prince's joyriding, tarnished image".
But Clarence House said plans for the trip were first outlined in 2007.
It said: "Prince William joining a flight into operational theatre was under consideration last year, when plans were first being developed for his RAF attachment.
"Confirmation and detailed planning for the flights began at the beginning of April."
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.