LONDON — In a surprising courtroom reversal, Husnain Rashid, a self-described jihadist accused of encouraging a terrorist attack on the school of 4-year-old Prince George, the third in line to the British throne, changed his plea on Thursday and admitted a series of terrorism offenses that could bring life imprisonment.

The case fused two conflicting themes in the nation’s public life: its enduring preoccupation with the royal family — witnessed most recently in the marriage this month of Prince Harry and the American actress Meghan Markle — and the struggle to avert terrorism a year after a suicide bombing in Manchester followed by attacks on bridges over the River Thames in London.

According to court testimony, Mr. Rashid used an online messaging service in October to publish a photograph of Prince George’s school in London, with silhouettes of jihadists superimposed on it. He also gave details of the school’s address and a warning that, “Even the royal family will not be left alone. School starts early.”

While that threat inspired many headlines, prosecutors said the royal family was only one of many targets suggested by Mr. Rashid, 32, including soccer stadiums, British Army bases, Jewish institutions, polling booths, the Wimbledon tennis tournament and concert sites. He had also called for ice cream and fruit to be poisoned.