By Natasja Sheriff

NEW YORK (Reuters) - A former FBI agent testified on Friday in the trial of a man accused of murdering a New York boy in 1979 that an earlier suspect in the case told her he may have molested the young victim.

Pedro Hernandez, 54, a former grocery clerk, is on trial for kidnapping and murder in a case that hinges on his confession to police in 2012 that he choked 6-year-old Etan Patz, stuffed him in a box and left him in a New York alley.

Patz vanished as he walked alone for the first time to a school bus stop in his Manhattan neighborhood on May 25, 1979. His disappearance sparked a national movement to find missing children, with his picture one of the first to appear on milk cartons.

Defense attorneys say Hernandez is mentally ill and his confession was coerced by police.

They say the real killer is Jose Antonio Ramos, whose girlfriend used to walk Patz to school. For years, he was the prime suspect.

Testifying in state Supreme Court, former Federal Bureau of Investigation Special Agent Mary Galligan said Ramos told her in a 1991 interview that a boy he took to his apartment for sex in 1979 could have been Patz.

Ramos said he met the boy who he called Jimmy in a downtown Manhattan park and that Jimmy was 8 or 9 years old and lived with his aunt in uptown Manhattan.

Ramos indicated that he molested the boy and put him on a subway train home, she testified.

Galligan worked on the Patz case for about ten years, starting in November 1989, and interviewed Ramos during her stint on the case. She later served as a high-ranking FBI officer in the investigation of the Sept. 11, 2001 attacks.

Ramos served 27 years in a Pennsylvania prison for the rape and molestation of three young boys in the 1980s. He is in prison now for breaking sex offender registration laws.

A jail house informant testified earlier that Ramos told him he sexually abused Patz and boasted that the boy's body would never be found. Ramos told him the boy was dead but said there was no proof, he testified.

Patz has never been found. He was declared dead in 2001.

Hernandez was questioned and arrested in 2012 after police got a tip he confessed to the crime to a church prayer group in New Jersey.

(Editing by Ellen Wulfhorst and Chris Reese)