A former U.S. ambassador formally pleaded guilty Friday to working for Cuba’s spy service for decades and was sentenced to 15 years in prison, bringing a quick end to a case that prosecutors described as one of the longest-running betrayals of the U.S. government in history.

Victor Manuel Rocha, the former U.S. ambassador to Bolivia, was indicted in December on charges that he spied for Cuba’s intelligence agency for more than 40 years. Rocha, who lives in Miami, originally pleaded not guilty in mid-February, then reversed course later that month.