Prince William flew into Afghanistan for a secret visit over the weekend to meet with British troops, a royal official said Tuesday.

William, 25, piloted a C-17 Globemaster transport plane on part of the flight to Kandahar in the country's troubled south Sunday, according to a spokesman for Clarence House, the official residence of William's father, Prince Charles.

"Obviously, one day he's going to be head of the armed forces," the spokesman said, speaking anonymously in line with royal policy. "It was going to be natural for him to see operations in the theater."

William, second in line for the British throne after his father, spent three hours on the ground talking with troops. He then flew back by way of the Al-Udeid airfield in Qatar, returning to Britain on Monday afternoon.

The spokesman said he did not know exactly how long William was at the controls during the trip, which took a total of about 30 hours, but said the prince was not the pilot when the plane took off and landed.

News of the trip appeared on the Wednesday front pages of several British papers and was likely to give William a dose of good publicity after a spate of critical coverage.

Commentators had been clucking at some more frivolous flights: landing his air force helicopter at the home of his girlfriend's parents and taking a Chinook helicopter to his cousin's bachelor party. The military said both flights were part of the prince's training, but critics complained that William was using military aircraft as a taxi service.

William's trip to Kandahar also had echoes of his brother's deployment to Afghanistan, where Britain has some 7,500 soldiers in the fight against Taliban insurgents.

Prince Harry recently returned from Helmand province in southern Afghanistan after his presence on combat duty leaked to the media. Harry was a forward air controller, responsible for directing air support in ground operations.