The Metropolitan Police confirmed a man was ordered to verify his identity by two officers about 6pm on Wednesday.
Prince Andrew said in a statement: "The police have a difficult job to do balancing security for the Royal Family and deterring intruders, and sometimes they get it wrong.
"I am grateful for their apology and look forward to a safe walk in the garden in the future."
The confrontation came after an intruder was able to scale a fence and get inside the palace on Monday night, before being arrested.
A police spokesman said: "The man was satisfactorily identified. No weapons were drawn and no force was used.
A security review has been launched following Monday night's suspected burglary.
Police said the man was found shortly before 10.30pm "in an area currently open to the public during the day" and arrested for burglary, trespass and criminal damage.
A second man was arrested outside the palace for conspiracy to commit burglary.
Both men have been bailed to return to a central London police station while enquiries continue.
The Queen made her traditional appearance at a Highland Games as details of the break-in emerged.
She was joined by the Duke of Edinburgh and the Prince of Wales at Aberdeenshire's Braemar Gathering, where the royal party watched pipe bands and dancers perform