A British high school student has apologized to Prince Harry for hugging his wife, Meghan, Duchess of Sussex, when she visited his school.

Aker Okoye, 16, embraced Meghan and called her "beautiful" during her surprise visit Friday to Robert Clack School in Dagenham, east London, to mark International Women's Day on Sunday.

The teenager seized the moment when the duchess invited a "brave young man" to come up discuss the importance of March 8.

After leaning in for what appeared to be a kiss on the cheek, Okoye boldly told his schoolmates: "She really is beautiful, innit."

The assembly hall immediately erupted in cheers from other students and Meghan was seen laughing and smiling at the compliment.

In a handwritten letter to Harry, published in The Sun newspaper, Okoye told the prince that he hoped his actions weren't out of line.

"I hope you didn't mind me cuddling your wife," he wrote, adding that he was "just overwhelmed and shocked to see her arrive at my school."

Okoye, who is head boy at the school, went on to say it was "a pleasure to hear her (Meghan's) speech and to speak in front of her as well. She is truly inspirational."

The cheeky student signed off by saying he hoped to meet the duke one day and wished the royal couple "good luck for the future."

Speaking about the viral moment on the "Good Morning Britain" TV show on Monday, Okoye said he reached out to Harry in a bid to avoid controversy.

"There was an Instagram comment on a post that I was on, and they said if I'm dead in the next six months we know who sent the hit out. I thought 'Ooh, let me cover myself.'"

CNN has reached out to Okoye for comment.

Meghan's appearance at the school was her final solo royal engagement as a senior royal before she and Harry officially step down on March 31. During her address, she encouraged young men to "value and appreciate" the women in their lives and to "set the example for some men who are not seeing it that same way."

The royal couple will take part in their last official scheduled engagement Monday when they attend the Commonwealth Day service at London's Westminster Abbey alongside other senior members of the royal family.

The-CNN-Wire