Defense Secretary Caspar W. Weinberger yesterday contradicted Secretary of State Alexander M. Haig Jr. on an important element of NATO nuclear weapons policy but, in an effort to smooth over the dispute, the administration later contended both men were technically correct.

At issue was the North Atlantic Treaty Organization's long-discussed first-use option involving nuclear weapons--firing a demonstration shot, normally described as being over water, to show alliance resolve to resist at any cost a Soviet invasion of Western Europe.

The idea is regarded as popular with European officials because the nuclear weapon used in the demonstration would not land in a Western European country.

Although Weinberger vehemently contradicted Haig, NATO military officials in Europe told The Washington Post as recently as two weeks ago that the demonstrative-use plan continues to be viable. On Wednesday, Haig made a surprising public reference to the option in an appearance before the Senate Foreign Relations Committee, saying "there are contingency plans in the NATO doctrine to fire a nuclear weapon for demonstrative purposes. . . . "

The statement, from a recent NATO commander at a time when any talk of nuclear weapons in Europe is highly controversial, was widely publicized.

Asked about Haig's remark in an appearance before the Senate Armed Services Committee yesterday, Weinberger declared, "There is absolutely nothing in any of the plans with which I am familiar that contains anything remotely resembling this, nor should it."

In late afternoon, as the nation's press services carried stories about the apparent contradiction, the White House and the Pentagon released a statement that concluded both men were technically correct.

Haig was termed correct, the statement noted, because "NATO, a number of years ago identified the so-called demonstrable use as a possible option."

Weinberger was correct, the statement said, because "there is no precise NATO military plan, and there have always been significant doubts expressed in NATO, doubts that the U.S. shared, about the utility of this option."

At the end of the business day, White House communications director David Gergen attempted to cool the matter by reiterating that both men were correct and by pointing out that they had met for breakfast at the State Department.

One irony of the episode is that Haig's original statement was an attempt to put a favorable slant on a question he was asked about a remark last month by President Reagan.

Reagan had said he could imagine a situation "where you could have the exchange of tactical nuclear weapons against troops in the field without it bringing either one of the major powers to pushing the button." That remark, interpreted to mean the United States would wage a nuclear war in Western Europe, caused a flurry of criticism here and abroad.

Haig's statement caused little stir yesterday in Europe, where the demonstrable-use plan, that supposedly would leave European land untouched, is far less frightening than the notion that some U.S. nuclear weapons would be used against an invader on NATO soil.

The British Foreign Office said: "It has always been recognized that NATO strategy embraces actions which would be primarily demonstrative in effect."

In Bonn, according to a Reuter dispatch, sources said that the question of first use of nuclear weapons was hypothetical but that a demonstrative response was not automatic.

Several senators voiced concern yesterday that Haig's remarks would be used as another sign that the United States is favorably inclined toward use of nuclear weapons.

At the Armed Services Committee hearing, Sen. John W. Warner (R-Va.), a former Navy secretary, said Haig's remark about the warning shot had triggered fresh concern about U.S. nuclear war policies.

Warner said he believes Haig was referring to a "fragment of a very early plan, but it's not one that is currently considered by NATO."

"That's exactly correct, senator," Weinberger responded.

A second irony is that eventually Weinberger's statement criticizing demonstrative use may be the one that creates new problems for U.S. nuclear deployment in Europe.

A former Carter administration official involved in NATO affairs said yesterday that, like Weinberger, U.S. officials had for years been critical of a nuclear demonstration because it "showed a lack of determination."

But he added that the option remained popular with Europeans and, since it is only one of several, had not "faded away."