During a visit to an electronics company in Scotland, Prince Philip had looked at a messy fuse box and said it looked "as though it was put in by an Indian".
Within hours, a Buckingham Palace spokesman said: "The Duke of Edinburgh regrets any offence which may have been caused by remarks he is reported as making earlier today. With hindsight, he accepts what were intended as light-hearted comments were inappropriate."
The retraction followed a barrage of hostile reaction to his comment. Prince Philip has previously made remarks that have proved offensive to minority groups.
In May, he angered deaf people with a comment about a Caribbean music band. During a visit to the Welsh Assembly, the Duke met a group from the British Deaf Association, pointed to the musicians, and said: "Deaf? If you are near there, no wonder you are deaf."
In 1995, he asked a Scottish driving instructor: "How do you keep the natives off the booze long enough to pass the test?" And on a visit to China in 1986 he told British students: "If you stay here much longer you'll all be slitty-eyed."
His latest comment came as he toured the Racal-MESL factory near Edinburgh before unveiling an award for its rail safety technology.
As the Duke looked at the fuse box, which appeared to be less sophisticated than other equipment in the factory, Terry Nisbet, the managing director, noticed his interest and joked: "That's the national grid." The Duke replied: "It looks as though it was put in by an Indian."
Kumar Murshid, chairman of the National Assembly Against Racism, condemned the Duke's remark yesterday as "absolutely abysmal and disgraceful.
"This sort of thing is of great concern to us because people look up to the Royal Family and expect them to set an example to the public," Mr Murshid said. "The reality is that they still have considerable influence."
A spokeswoman for the Commission for Racial Equality described the Duke's comment as "very unfortunate. We look to the Royal Family to be positively promoting racial equality."
However, Dr Shanfi Kauser, secretary of the Islamic Centre in Glasgow, said he was not offended by the Duke's comment. He said: "He is a nice man and I don't think he has done anything out of malice. On other occasions he has been very complimentary to us. I think he should be excused."
A spokesman for the Scottish National Party said: "This is an extremely unfortunate comment which smacks of xenophobia. If anyone else had said it I'm sure the repercussions for them would be far more severe.
"This is, of course, not an isolated incident. He needs to respect other races and cultures far more than he does."
n Jeffrey Archer refused to apologise yesterday for his remarks that black women in Britain used to be fat and badly dressed.
The peer, who is seeking the Tory nomination for Mayor of London, said his comments had been "taken out of context".
However, Michael Ancram, the Conservative Party chairman, described the remarks as "ill-judged". He said Lord Archer of Weston-super-Mare would be answerable to London members of the party in the selection contest.
Meanwhile, the singer and Tory supporter Patti Boulaye defended Lord Archer. "I am talking as a black woman who knows Jeffrey Archer. Jeffrey is not a racist," she said.