The U.S. Roman Catholic bishops ended a two-year effort to develop a comprehensive statement on nuclear weapons and war today with the adoption here of a 150-page pastoral letter that leaves them sharply at odds with most elements of current U.S. nuclear policy.

The vote of 238 to 9 came at the end of a special two-day meeting of the National Conference of Catholic Bishops, at which liberals and moderates steadily strengthened the anti-nuclear stance of a controversial third draft of the letter first made public a month ago.

The final document, titled "The Challenge of Peace: God's Promise and Our Response," rules out deliberate nuclear attack on civilian populations even in response to an attack on an American city, condemns first use of nuclear weapons on any scale and calls nuclear deterrence acceptable only as a temporary device while arms reductions are being pursued.

The Reagan administration fought to soften the letter, which now becomes the official basis for Catholic church teaching in the United States. The document had been softened somewhat in the draft, and the administration welcomed the changes. But many of them were reversed here.

As finally approved, the letter said, "We do not perceive any situation in which the deliberate initiation of nuclear warfare, on however restricted a scale, can be morally justified." That replaced language from the third draft saying: "We abhor the concept of initiating nuclear war on however restricted a scale."

The document calls for "immediate, bilateral, verifiable" agreements to "halt," instead of the third draft's "curb," the testing, production and deployment of new nuclear weapons.

In another shift back to language of the second draft, the pastoral letter states that the bishops "oppose," rather than "resist," the addition of first-strike weapons.

But an effort by liberal bishops to emphasize that the proposed MX missile system could be used as a first-strike weapon by moving mention of it from a footnote into the text was voted down by the bishops.

Conversely, the bishops voted to relegate back to a footnote this week a Jan. 15 defense of administration policy by White House national security affairs adviser William P. Clark and a portion of Defense Secretary Caspar W. Weinberger's annual report to Congress this year. Both stated that the administration does not deliberately target Soviet civilian populations. Their comments had been included in the third draft at administration behest.

The document retains language of the third draft giving "conditioned moral acceptance" to nuclear deterrents and relates that particularly to a U.S. "responsibility" to protect western Europe from either conventional or nuclear attack, but only if the deterrence is used as an interim step toward disarmament.

The bishops voted against most amendments proposed by conservatives. For example, conservatives were defeated on their proposal to strike a passage saying that there is "no justification for submitting the human community to this risk" of nuclear war.

And the bishops rejected an amendment by Archbishop Philip Hannan of New Orleans to justify use of the atomic bomb in World War II. Hannan accused his colleagues of "damaging the reputation of a president . . . and you don't have the right to do so."

The document explains "a just war" according to Catholic doctrine as including the principals of "proportionality" and "discrimination." Proportionality means that the good will outweigh the bad in a war, and discrimination refers to targeting military sites and leaving civilian populations unharmed. The devastation of a nuclear war would rule out both, particularly since the pastoral states it is unlikely a "limited" nuclear war could be carried out.

The bishops said there were different levels of authority in the document, with, generally, statements of moral principles binding on Catholics and applications to concrete situations subject to the possibility of differences of oppinion. Archbishop John Roach of St. Paul-Minneapolis, president of the conference, called the document "a very, very strong position on peace and one with which our people can live."

Cardinal Joseph L. Bernardin of Chicago, chairman of the five-member bishops' committee that drafted the three versions of the pastoral, said that already the process has given rise to many discussions." Archbishop James A. Hickey of Washington, D.C., said of the pastoral , "I think thes es a very clear, straightforward declaration . . . We can't use weaponry that will be immoral."

But Hannon of New Orleans said, "As far as I'm concerned it's totally nonbinding and that's what I'm going to tell our people."