When Moorhead Kennedy was tied to a chair in a Tehran prison in December 1979, after being taken hostage by the Iranians, he remembered some biblical words that related the plight of the imprisoned Apostle Peter:

"So Peter was kept in prison; but earnest prayer for him was made to God by the church . . . . Peter was sleeping between two soldiers, bound with two chains, and sentries before the door were guarding the prison; and behold an angel of the Lord appeared . . . and rescued [him]."

When he was released, Kennedy said, he was determined to repeat those words in public -- and he finally got his chance yesterday -- from the pulpit at the Washington Cathedral, where about 2,000 people gathered for an interfaith thanksgiving service.

About 10 of the 53 former hostages, mostly residents of the Washington area, attended the 40-minute service, and remained afterward to greet a crush of well-wishers and sign autographs.

The service was conducted jointly by Bishop John T. Walker of the Episcopal diocese of Washington, Archbishop James A. Hickey of the Catholic archdiocese of Washington and Rabbi Mendel L. Abrams, president of the Washington Board of Rabbis.

In his litany, Walker praised former president Carter and Algeria for their roles in securing freedom for the captive Americans.

Speaking for the former hostages, Col. Thomas A. Schaefer, who was military attache of the embassy, said he and others were bolstered during their captivity by their religious faith and prayers.

"Thank you for your prayers and your support," he said, "for the love, the affection, the prayers, the total support you have given us . . . I would give this message in two brief words: Thank God -- thank God it is over."

As the principal speaker, Schaefer replaced L. Bruce Laingen, the senior official among the former hostages, who was homebound with a cold yesterday. "He can hardly talk this morning," Schaefer told the audience.

When the service ended, hundreds of spectators crowded around the former hostages and their families, who occupied the front rows facing the altar banked with yellow chrysanthemums, snapdragons and daisies.

Schaefer, looking relaxed and greeting friends and strangers alike, lifted and hugged Christopher Sabot, 5, who was brought to the service by his mother, Judith.

Nearby, ex-hostage John W. Limbert Jr. was cheerfully signing one autograph after another for eighth-grade students from National Cathedral School.

Among those who greeted the ex-hostages was senior American diplomat Ellsworth Bunker, who offered a handshake and a "well done" for each.