FALL RIVER — A cousin of ex-New England Patriots player Aaron Hernandez was spared jail time only because of her advanced cancer, a judge said Tuesday in sentencing her to two years of probation.

Tanya Singleton pleaded guilty to refusing to testify before a grand jury even though she had been granted immunity.

"Ms. Singleton's health is the only reason she is not being placed in jail," Fall River Superior Court Judge E. Susan Garsh said. County jail officials made it clear they could not meet Singleton's medical needs, the judge said.

Singleton, 38, of Bristol, Connecticut, is subject to GPS monitoring for the entire probationary period, the first year of which must be spent confined to her home, except for medical and legal appointments. She also was ordered to have no contact with Hernandez, any other suspects or witnesses, except for her father, sister and two close friends.

Singleton had refused to testify before a grand jury investigating the July 2013 slaying of Odin Lloyd.

Lloyd's bullet-riddled body was found in an industrial area near Hernandez's home in North Attleborough. He was dating the sister of Hernandez's fiancee.

Hernandez has pleaded not guilty to killing Lloyd and is being held without bail. He also has pleaded not guilty in the 2012 killings of two men in Boston.

Singleton, who has been undergoing treatment for a recurrence of breast cancer, pleaded guilty to criminal contempt and had faced up to 2 1/2 years in jail.

"Ms. Singleton's willful conduct was an assault on the rule of law," Garsh said.

The sentence was in line with what prosecutors requested.

Singleton "perverted her sense of loyalty" and had an "utter disdain" of the legal process in trying to protect Hernandez, prosecutor William McCauley said, noting that she had received financial assistance from her NFL star cousin.

She put Hernandez ahead of her children, who were ages 4 and 7 at the time, McCauley said, even arranging for their care, knowing she risked imprisonment.

Singleton's attorney, E. Peter Parker, asked for a year of home confinement.

"She chose family loyalty ... over civic duties," a choice most people would make under similar circumstances, Parker said.

Prosecutors said Singleton has material information about Hernandez and the movements of his friends Ernest Wallace and Carlos Ortiz, who both pleaded not guilty to murder and accessory charges in the Lloyd killing.

Singleton also refused to testify in the Boston double killing case and is facing another contempt charge to which she intends to plead guilty.