VATICAN CITY — A former Holy See envoy to Washington was sentenced here Saturday to a five-year prison term for viewing and sharing child pornography, the first time on record that the Vatican has convicted one of its own onetime diplomats for such crimes.

The punishment for Monsignor Carlo Capella, which included a fine of 5,000 euros, was just shy of the five year, nine-month term that prosecutors requested. The code of this city-state calls for imprisonment of up to five years for possessing and distributing child pornography but says penalties can increase if a “considerable quantity” of material is involved.

“The mistakes that I have made are clear,” Capella said in a statement just before his sentencing, where he said his interest in child pornography came during a period of emotional “weakness.”

The two-day trial brought quick closure to a case in which Capella was recalled from Washington last year after the Vatican rebuffed a U.S. attempt to drop diplomatic immunity. Capella, who also faced charges in Canada, will serve his sentence in a cell within the Vatican police barracks. He could also be removed from the priesthood in an upcoming canonical trial.

Capella’s criminal trial came as the Roman Catholic Church finds itself under pressure to more forcefully address the issues of clerical abuse and enact stricter punishments for those convicted of sex crimes. The church is dealing with high-profile abuse cases around the world, and Pope Francis faces a major decision about how to handle a crisis in Chile, whose bishops have offered to resign en masse over the coverup of sex abuse crimes in their nation.

Capella’s case had little precedent. Five years ago, a Polish archbishop, Józef Wesolowski, was recalled from a diplomatic posting and later ordered to stand trial on child sex abuse-related charges. He died before the trial began.

Saturday, with several pool reporters in the courtroom, a tribunal president read the verdict and said Capella was “guilty of the charge levied against him.”

“It’s certainly a strong punishment,” said Michael Sean Winters, a columnist for the National Catholic Reporter. “I think there was a mistake — [Capella] should have been tried in the U.S. or Canada. Still, they’re going after these guys. That is how it should be.”

Francesco Zanardi, an Italian survivor of clergy sex abuse and president of the Abuse Network, said that people who share and view child pornography energize the market, which in turn “actually produces plenty more victims.”

At the opening of his trial Friday, Capella said that during his time at the Holy See’s embassy in Washington — a posting that began in 2016 — he had become a compulsive viewer and sharer of child pornography, although he came to see his behavior as “repugnant.” He said he had started to view child pornography after falling into a crisis that he associated with the move to the District, where he said he had little fulfilling work to do.

A police investigator said during the trial that he had found several dozen files — photographs, drawings and videos — on Capella’s electronic devices, including footage of a small child in an explicit sexual act.

“I am sorry that my weakness has affected and caused pain to the diocese, the church, and the Holy See,” Capella said Saturday. He said he was “repentant” but hoped “this situation can be considered just an accident along the path of my life as a priest.”

Stefano Pitrelli contributed to this report.