Former News of the World editor Andy Coulson, a onetime aide to British Prime Minister David Cameron, was sentenced to 18 months in prison Friday for participating in a conspiracy to hack the phones of celebrities, politicians and crime victims.

Three other former journalists and private investigator Glenn Mulcaire all received shorter sentences.

Coulson was convicted last week after an eight-month trial stemming from revelations of illegal eavesdropping at the now-defunct Rupert Murdoch-owned tabloid.

Another former editor, Rebekah Brooks, and four others were acquitted.

Coulson faces a retrial on two charges of bribing police officers for royal phone directories.

The defendants have said they did not know phone hacking was illegal, though the judge said they knew it was ‘‘morally wrong.’’

Judge John Saunders acknowledged that ‘‘there will be those who will be outraged’’ that the sentences were so short. But he said the legal maximum for phone hacking was two years in prison, regardless of the number of victims.

Saunders said he was reducing Coulson’s sentence from the maximum to reflect aspects of ‘‘good character’’ he had shown in helping others, and because the case had taken so long to get to court.

The judge sentenced former journalists Greg Miskiw and Neville Thurlbeck to six months in jail, while another reporter, James Weatherup, received a suspended four-month sentence and community service.