LONDON — Andy Coulson, a former top aide to Prime Minister David Cameron, was sentenced to 18 months in prison Friday for presiding over phone hacking on a massive scale when he was editor of a Rupert Murdoch-owned tabloid.

Coulson, 46, was the only one of seven defendants to be convicted last week after one of the longest and most expensive trials in British history. The trial offered testimony by celebrity witnesses such as actor Jude Law and a peek into the often-seamy relationships among the press, politicians and police. It had riveted many in Britain since October.

Three other former journalists and a private investigator at the now-defunct News of the World, who separately had pleaded guilty to accessing voice-mail messages left on cellphones, were also sentenced Friday at London’s Old Bailey courthouse.

Neville Thurlbeck, former senior reporter, and Greg Miskiw, former news editor, were handed jail terms of six months each. Former reporter James Weatherup was given a suspended sentence of four months and ordered to perform community service.

Save 75% on a Digital Subscription Today

Private detective Glenn Mulcaire, who has already spent time behind bars for a previous phone-hacking conviction, received a suspended six-month jail term.

The sentences were pronounced by a judge who called it “unforgivable” that the News of the World had gone as far as tapping into the voice-mail messages of a 13-year-old girl who had been kidnapped and who was later found slain.

Revelations of that incident shocked Britain three years ago and triggered a public and political backlash against Murdoch, whose media empire had made him one of this country’s most influential people. He shut down the 168-year-old News of the World and was summoned to answer questions before Parliament.

Lawmakers and senior police officials who had cozied up to the Australian media magnate and his newspapers also came in for withering criticism. The head of Scotland Yard resigned.

Murdoch’s trusted lieutenant, Rebekah Brooks, stepped down as head of his British newspapers and went on trial alongside Coulson. Brooks, 46, was accused of conspiring to hack phones, bribery and obstruction of justice, but the jury acquitted her of all charges. Her husband and former personal assistant were also cleared.

Coulson, who was Brooks’ colleague at the News of the World and her lover when both were married to other people, faces a retrial on corruption charges stemming from allegations that he paid police for a phone directory of the royal household.

Coulson’s phone-hacking conviction is acutely embarrassing for Cameron, who promoted him to chief communications adviser after he resigned as editor of the News of the World. By that point, phone-hacking was already a known practice at the paper, but Cameron accepted Coulson’s assurances that he himself was unaware of it and that the practice was confined to one or two “rogue” reporters.

Cameron has apologized before Parliament for hiring Coulson, but the opposition Labor Party continues to lambaste him.

Cameron said Friday’s sentences showed “It’s right that justice should be done and no one is above the law.”