A man has been detained by police after appearing to throw eggs at King Charles and Camilla, the Queen Consort, during a walkabout in York.

Several police officers were seen restraining the suspect on the ground behind temporary fencing set up at Micklegate Bar in the city for the king’s visit on Wednesday.

The king and queen consort were being welcomed to York by city leaders when a protester apparently threw three eggs at them, all of which missed, before the pair were ushered away.

The man was heard to boo the royals as he threw the eggs and to shout “this country was built on the blood of slaves” and “not my king” as he was being detained by about four police officers.

One of the eggs appeared to be fended off by the sheriff of York, Suzie Mercer, who was part of the group of officials welcoming the king.

Some people in the crowd started chanting “God save the king”, while others shouted “shame on you” at the protester.

As police were detaining the man, Charles appeared unfazed and continued to greet the crowds. He was taking part in a traditional ceremony in which the sovereign is officially welcomed to York by the lord mayor through the gates to the city.

The king and queen consort were visiting Yorkshire on Wednesday to carry out a number of engagements. They were in York to attend the unveiling of a statue of Queen Elizabeth II, the first to be installed since her death.

Speaking at the ceremony at York Minster, Charles said: “The late Queen was always vigilant for the welfare of her people during her life. Now her image will watch over what will become Queen Elizabeth Square for centuries to come.”

The 2-metre sculpture, weighing 1.1 tonnes and made from lepine limestone from France, was designed to celebrate the late Queen’s platinum jubilee and was completed in August, a month before her death.