Dr. John Rock, 94, who in the late 1950s helped develop the birth control pill that revolutionized human sexual behavior, died Dec. 4 at a hospital in Peterborough, N.H., after a heart attack.

Dr. Rock was an expert in fertility. In 1944, he became the first scientist to fertilize a human egg in a test tube and he was one of the first to freeze human sperm cells without damaging their potency.

But he was known chiefly for his work with three other physicians, Gregory Pincus, C.M. Phang and Selzo Garcia, in developing the first oral contraceptive. Approved by the Federal Drug Administration in 1960, birth control pills have since been taken almost routinely by millions of women, and their use is generally recognized to have prevented the conception of millions of unwanted children.

The decades since birth control pills became readily available have also been accompanied by an unprecedented degree of sexual freedom for married and unmarried men and women and a major change in the status of women in society.

Dr. Rock was born and raised a Roman Catholic, and he remained committed to the church all his life. But his enthusiastic support of birth control and the pills he helped develop set him at odds with official church doctrine. He never was able to convince the Vatican that his oral contraceptives, which kept women from ovulating, were a form of natural birth control and thus in keeping with church teachings.

"I believe the new pills to be completely physiological and therefore in accord with nature," he said. "Their use is completely moral."

During the 1960s, Dr. Rock testified before congressional committees and gave dozens of lectures and speeches throughout the country warning of the dangers of overpopulation and promoting contraception and birth control. "We must face up to the problem of man's urge to copulate and its fearsome results in the population explosion," he said at a 1965 symposium in Washington.

He wrote a popular book called "The Time has Come," which advocated a change in the church's stand against contraceptives and called for research into methods of contraception that would be acceptable to all religious faiths.

The book was denounced by the newspaper of the Catholic Archdiocese of Boston, which said Dr. Rock had better "watch his step or else." Dr. Rock took the criticism in stride. "They couldn't excommunicate me. It was as much my church as theirs," he said at the time.

To critics who argued that the pill posed a threat to the health of the women who used it, Dr. Rock insisted that the pill was safe and that pregnancy or what at the time would have been an illegal abortion was a greater hazard to a woman's health.

Born in Marlborough, Mass., Dr. Rock was a graduate of Harvard University and Harvard Medical School, and he was a member of the medical school faculty for 30 years before he retired in 1956.

He was director of a fertility and endocrine clinic at a hospital in Brookline, Mass., and he was head of a reproductive clinic that he founded there. His development of the birth control pill stemmed initially from his work on problems of infertility.

It was in Brookline and elsewhere during the 1950s that Dr. Rock conducted the first tests of the birth control pills. Hundreds of women took the pills, which were composed of synthetic hormones, daily for 20 days of the menstrual cycle, and none of the first group of women tested became pregnant.

In recent years, Dr. Rock had lived in a 100-year-old house in Temple, N.H.

His wife, Anna, died in 1961. He is survived by three daughters, A.J. Levinson of New York City, Rachel Achenbach of Boxford, Mass., and Martha LeFevre of Milton, Mass.; 19 grandchildren, and five great-grandchildren.