The intruder who caused a security breach at the Queen's official Scottish residence was a reporter from the Sunday Times.
The breach came three days before Prince Charles is due to visit
The man is believed to have posed as a tourist and then a workman before being stopped at the Palace of Holyroodhouse, in Edinburgh.
Security staff intercepted him at noon on Thursday but he managed to escape.
Lothian and Borders Police criticised the newspaper for "wasting police time".
The incident happened 72 hours before the Prince of Wales is due to visit the palace.
The breach comes a fortnight after a fathers' rights protester scaled the walls of Buckingham Palace dressed as the superhero Batman.
It follows other security incidents at the new Scottish Parliament building nearby where two newspapers also sent journalists into restricted areas.
Lothian and Borders Police have launched an investigation into the palace breach.
The Queen is due to stay at Holyrood in two weeks time during a visit to open the Scottish Parliament.
The newspaper said in a statement: "After a series of breaches in Buckingham Palace, Westminster and the Scottish Parliament the Sunday Times decided to test security at the Palace of Holyrood, the official residence of the Queen in Scotland.
'Agreed to co-operate'
"The ST undertook these investigations in advance of the Queen opening the new Scottish Parliament next month and Prince Charles staying at the palace this weekend.
"A reporter wearing a hard hat was able to gain entry to a restricted area unchallenged in the State rooms adjacent to the Queen's bedroom.
"He was under instructions to remain in that area until challenged which happened after 20 minutes.
"A construction worker asked him to report to reception and he then left the palace.
"After the incident we notified Lothian and Borders Police of what happened. We have agreed to co-operate with the police who have agreed to investigate how this breach of security took place."
Lothian and Borders Police criticised the Sunday Times for wasting police time.
The force's assistant chief constable Ian Dickinson said: "The events yesterday, at the Palace of Holyroodhouse, are the latest example of press seeking to make journalistic capital from our
"In an open society, the balance between security and important public access to our democratic process and national heritage is delicate and difficult.
"A considerable amount of valuable police time was wasted for five hours before the Sunday Times made a telephone call to the Lothian and Borders Police.
"Such a waste of vital police resources is certainly not in the public interest and completely counter to the purpose which the newspapers claim to pursue."
Independent MSP Margo MacDonald said: "I am now seriously concerned that the relaxed attitude we had towards this sort of behaviour has been overtaken by these events.
"I want to be assured that the security officials at Holyrood palace are taking advice from the police to make sure there are no gaps in the overall plan."