President Reagan, declaring that he is willing to go "the extra mile" in pursuit of arms control with the Soviet Union, said yesterday that the United States would dismantle a working missile submarine to continue complying with the unratified SALT II treaty he used to describe as "fatally flawed."

Going substantially beyond the course of action senior administration officials had predicted, Reagan said the United States would dismantle a Poseidon nuclear submarine to stay within the missile limits of the treaty rather than dry-dock it.

Secretary of Defense Caspar W. Weinberger, supported by conservatives within and outside the administration, had recommended that Reagan announce the end of American adherence to SALT II because of alleged Soviet violations, administration sources said. Other administration officials had recommended a "gray-area" solution -- putting the Poseidon in dry dock, but reserving the right to reactivate it at any time.

Though Reagan denounced the Soviets for treaty violations and a continuing "unparalleled and unwarranted military buildup," his action yesterday did not require the Soviets to change any specific activity as a condition for continued U.S. observance of the treaty.

In a statement read to reporters by national security affairs adviser Robert C. McFarlane, the president said: " . . . I have decided that the United States will continue to refrain from undercutting existing strategic arms agreements to the extent that the Soviet Union exercises comparable restraint and provided that the Soviet Union actively pursues arms reduction agreements in the currently ongoing nuclear and space talks at Geneva."

Reagan's action contradicted the expectation of administration officials who said last week that they expected him to take the option of dry-docking the 16-missile Poseidon submarine rather than dismantling it as required by SALT II agreements. The treaty was signed by President Jimmy Carter and the late Soviet leader Leonid Brezhnev in 1979 but withdrawn from Senate consideration after the Soviet invasion of Afghanistan. It puts a ceiling of 1,200 on multiple-warhead missiles.

The United States will exceed the ceiling late this summer when the Trident submarine USS Alaska, armed with 24 nuclear missiles, begins sea trials.

Yesterday's decision by Reagan was considered a victory for Secretary of State George P. Shultz and McFarlane. It reflected pressure from the Senate and European allies to stick with SALT II. One source said that British Prime Minister Margaret Thatcher, a firm Reagan friend and ally, sent a "strong communication" to the president urging full compliance.

"The president was influenced by congressional input and input from the allies," said one administration official, who added that Shultz had emphasized the allies' support for continued SALT adherence in three cables last week from Lisbon, where he was meeting with foreign ministers of the North Atlantic Treaty Organization.

Meanwhile, McFarlane was making a similar point to the president about opinion in the Senate, which last week passed a resolution strongly urging at least modified compliance with SALT II.

Reagan reportedly discussed his general views with McFarlane and White House chief of staff Donald T. Regan en route to Washington after a political speech in Birmingham, Ala., last Thursday. McFarlane then prepared a decision document for the president on Saturday that laid heavy emphasis on the views of the NATO allies relayed to him by Shultz.

The president formally approved the decision that afternoon and sent communications to the allies and Soviet leader Mikhail Gorbachev late Sunday informing them of his course of action. Weinberger, who had advocated that Reagan renounce the treaty because of alleged Soviet violations of it, was told of the general decision about compliance but not formally notified about dismantling of the submarine until yesterday, according to White House sources.

Officials said one reason Reagan decided to dismantle the sub rather than dry-dock it was the Navy's desire to make use of the vessel. "Dismantling," in treaty terms, would allow the submarine to be converted into an attack boat, a carrier for Tomahawk cruise missiles or a training sub.

The United States can stay within terms of the treaty by removing the firing tubes of the Poseidon submarine within six months after the Alaska begins sea trials. Pentagon officials said yesterday that the sub that will be dismantled is the USS Sam Rayburn, commissioned in 1964.

"The argument that the sub would be in useful service if dismantled rather than dry-docked appealed to Reagan," said an official familiar with the decision.

Shultz, obviously pleased with Reagan's action yesterday, reacted by saying: "I'm sure Secretary Weinberger and I will agree it's the wisest conceivable decision."

Weinberger, who officials said was not pleased, issued a terse statement through a spokesman: "We are in full support of the president's decision and have begun work on the assignment given to us."

The spokesman was referring to a directive Reagan issued yesterday in his statement of compliance calling for the Department of Defense "to conduct a comprehensive assessment aimed at identifying specific actions which the United States could take" as a "proportionate response" to Soviet violations of existing arms agreements.

Richard N. Perle, assistant secretary of defense for international security policy and the most outspoken administration critic of Soviet treaty violations, said he was satisfied with the president's decision because Reagan had adopted his view that "a double standard should not be allowed" in which the United States complies with strategic arms agreements while the Soviet Union violates them.

In announcing his continuing adherence to SALT II, Reagan left open the possibility he may renounce it in the future if Moscow fails to abide by its provisions.

"The pattern of Soviet violations, if left uncorrected, undercuts the integrity and viability of arms control as an instrument to assist in ensuring a secure and stable future world," Reagan said. "The United States will continue to pursue vigorously with the Soviet Union the resolution of our concerns over Soviet noncompliance. We cannot impose upon ourselves a double standard that amounts to unilateral treaty compliance."

McFarlane said Reagan would have an opportunity to make another assessment after Weinberger reports to him on Nov. 15 about appropriate responses to reported Soviet violations. The president will have an additional opportunity next summer, when another nuclear submarine similar to the Alaska is to go to sea.

"As these later milestones are reached, I will assess the overall situation in light of Soviet actions correcting their noncompliance and promoting progress in Geneva and make a final determination of the U.S. course of action on a case-by-case basis," Reagan's statement said.

The president refused to comment on his action in response to shouted questions from reporters at a Rose Garden ceremony yesterday afternoon honoring the new National Basketball Association champions, the Los Angeles Lakers.

Reagan made SALT II a centerpiece of his 1980 campaign against President Carter, even though the treaty had been withdrawn from ratification. Reagan and his strategists used the treaty as a political symbol of a "failed foreign policy" characterized by indecision and gullibility about Soviet intentions.

Within a year of his election, however, Reagan announced that he would not undercut the treaty so long as the Soviets abided by its provisions. In February of this year, the administration charged that the Soviets had violated the treaty on three counts.

One of these reported violations is deployment of the SSX25, a new intercontinental ballistic missile prohibited by the treaty. Reagan said the United States "reserves the right to respond in a proportionate manner at the appropriate time," and mentioned the U.S. Midgetman missile, which will not be operational for at least two years.

McFarlane said yesterday that Reagan still believes that the treaty he plans to comply with is "fundamentally flawed" because of its high ceilings on missile deployment and verification problems.