Mexico’s ambassador to Argentina who was caught on camera trying to steal a book from a bookstore in October has resigned, blaming yearslong health problems that stemmed from a brain tumor, officials said.

Mexican President Andrés Manuel López Obrador on Monday called the case "painful" and "sad."

Officials said late Sunday that Ambassador Óscar Ricardo Valero, 77, had resigned for health reasons. Mexico's Foreign Relations Secretary Marcelo Ebrard wrote on Twitter that Valero "is undergoing neurological treatment.”

He also described Valero, a career diplomat with a long pedigree in Mexico's left, as "a great person."

Mexican news media reported that Valero allegedly also tried to steal a T-shirt from an airport shop after he was called back to Mexico in early December.

At the request of relatives, Ebrard's office published a doctor's letter saying Valero had been diagnosed with a brain tumor in 2012 that resulted in "behavioral changes."

While the tumor was surgically removed years ago, the letter says behavior changes in the last 1 1/2 years — including traffic tickets and "difficulties in personal relationships" — suggests the tumor or its after-effects may have worsened.

Video of the bookstore incident in October appears to show the diplomat tucking a biography of Giacomo Casanova inside a newspaper and being stopped by security after passing a detector on the way out. The book’s cost was reportedly worth about $10.

MEXICO’S EX-PUBLIC SECURITY SECRETARY ARRESTED IN US, ACCUSED OF TAKING MILLIONS IN BRIBES FROM ‘EL CHAPO’ CARTEL

Valero pleaded diplomatic immunity and was never prosecuted, but he was recalled by Mexico’s foreign ministry after the footage emerged, BBC reported.

CLICK HERE TO GET THE FOX NEWS APP

The incident is especially embarrassing given López Obrador's main policy aim of promoting honesty among public servants.

The Associated Press contributed to this report.