Congressional incumbents swept to victory from coast to coast in 12 state primaries Tuesday, preserving their nearly perfect record for the year and confounding prophets of a toss-the-rascals-out political tide.

The narrowest incumbent escape Tuesday was that of four-term veteran Sen. Howard W. Cannon (D-Nev.), who turned back a stiff intraparty conservative challenge from Rep. James D. Santini (D-Nev.).

Cannon's razor-thin victory, by fewer than 1,000 votes, was easily the most dramatic of the year's busiest day of primaries, but it was of a piece.

All incumbent senators and members of Congress who sought renomination Tuesday were winners, and of the eight incumbent governors on the ballot all but Massachusetts Gov. Edward J. King prevailed. King lost the Democratic gubernatorial primary to former governor Michael S. Dukakis, whom King beat four years ago.

In all the primaries this year only eight congressional incumbents have been defeated, and five of those were in races against other incumbents as a result of redistricting. Just New York, Hawaii and runoffs in some Alabama, Florida and Georgia races remain.

Tuesday also was a day of victories for moderate and liberal candidates. In Wisconsin, the liberal view on nuclear arms policy prevailed as well. By more than 3 to 1 voters approved the year's first statewide resolution calling for a nuclear weapons freeze.

The elections also could be seen as a repudiation of the National Conservative Political Action Committee's intervention in two Senate primaries. NCPAC spent money on behalf of Santini and in opposition to Sen. Paul W. Sarbanes (D-Md.).

"It was a good day for progressives," Democratic National Committee Chairman Charles T. Manatt said yesterday.

The one notable exception to the leftward tilt Tuesday was in Minnesota, where former Democratic governor Rudy Perpich, a maverick and a fiscal conservative, upset state attorney general Warren Spannaus, the endorsed Democratic Farmer Labor Party candidate.

Spannaus is a protege of former vice president Walter F. Mondale, and his defeat was not welcome news in the Mondale presidential camp.

The incumbents' strength this year puzzles many political strategists, who have files stuffed with polls chronicling the voters' low regard for Congress and, presumably, a throw-the-rascals-out frame of mind.

"It's a very strange political year," said Leon Billings, executive director of the Democratic Senatorial Campaign Committee. "The stability is almost disconcerting."

One explanation is a familiar one: the incumbents' fund-raising edge in an time of vastly escalating campaign costs.

The other is psychological. Democratic pollster Peter Hart said yesterday that, despite the nation's economic woes -- or possibly because of them -- he has been expecting a good incumbent showing for some time.

"In periods of instability, people look to their moorings," he said. "This year, day in and day out, the headlines are filled with stories of war and economic misery." He compared the current political season with that of 1968, a vintage year for congressional incumbents despite the upheavals of the Vietnam war, assassinations and student and urban unrest.

Rounding out his safe-port-in-a-storm theory, Hart noted that the winners of four gubernatorial primaries are former governors: Dukakis in Massachusetts, Perpich in Minnesota and, earlier this year, former Democratic governors Bill Clinton in Arkansas and George C. Wallace in Alabama. Wallace won a plurality in his primary and faces a runoff Sept. 28.

The Cannon and Perpich victories came as the biggest surprises. The fallout in each case may be to give the Republicans an unexpected opening for November.

Republican strategists privately conceded that if Santini, the western "Boll Weevil" who sided with President Reagan on most economic votes, had won he would have been hard to beat. They can be expected to revive the allegations of corruption that have dogged Cannon and to pour maximum resources into the race.

This is particularly likely since Cannon's opponent is former state senator Chic Hecht, a Las Vegas businessman with close ties to Sen. Paul Laxalt (R-Nev.), who beat developer Rick Fore, a newcomer to Nevada who might have been vulnerable to carpetbagger charges.

Similarly, in Minnesota Spannaus was considered a more formidable fall candidate than Perpich. But the colorful Perpich, who said he didn't know he had won until he heard the radio when he woke up, demonstrated this week that he could still run a poorly financed race with little party support and win. His opponent is businessman Wheelock Whitney. Colorado

Former astronaut Jack Swigert swept past former fighter pilot Norm Sothan to win the Republican nomination by a 3-to-1 margin in the new 6th Congressional District, created by redistricting, in the Denver suburbs.

Swigert, 50, an Appollo 13 crew member, will face Democrat Steve Hogan. The new district is heavily Republican, but Swigert, who lost a bid for the GOP nomination to the U.S. Senate four years ago, was cautious. "You don't know how the economic condictions are going to be," he said. "That may work against us."

The incumbents in the other five districts were unopposed in their primaries, as was Democratic Gov. Richard D. Lamm, who is running for a third four-year term. He will face Republican John Fuhr, a veterinarian, who was also unopposed. Massachusetts

With 94 percent of the vote counted, Dukakis led King by 54 to 46 percent. The victory, after a bitter campaign, avenged King's upset of Dukakis when Dukakis was seeking a second term in 1978.

Dukakis immediately pronounced the results a referendum on Reaganomics. "I hope it's a message to the Reagan Administration ," he said. "Not just across this state but across the nation, because there are other states that are hurting as much, if not more."

Dukakis' Republican opponent is former Boston city councilman John W. Sears, who handily won a three-way race.

Sen. Edward M. Kennedy (D-Mass.) and GOP businessman Raymond Shamie were unopposed in their respective Senate primaries.

Another big-name winner Tuesday was House Speaker Thomas P. (Tip) O'Neill Jr. (D-Mass.), who overwhelmed a nominal opponent. Minnesota

Democrat Mark Dayton, heir to a department store fortune, won the Democratic nomination for the Senate over former senator Eugene J. McCarthy, who bid for a comeback 12 years after he left Congress.

Dayton will square off in November against Republican incumbent David S. Durenberger, who won his primary over token opposition. The Democrat says he will try to make the campaign a referendum on Reagan's economic programs.

In the Democratic gubernatorial race, Perpich trailed for most of the night, but pushed past Spannaus with a late surge from his home area in the northern part of the state. With 3,935 of 4,067 precincts reporting, Perpich led by 247,830 to 235,954.

His Republican opponent is moderate businessman Wheelock Whitney, who defeated conservative Lt. Gov. Louis Wangberg in the Independent-Republican primary. Republican incumbent Gov. Albert Quie, facing high unemployment, low farm prices and a state budget crisis, chose not to seek reelection. Nevada

After the Cannon victory over Santini, the most closely watched race was in the newly created 2nd Congressional District, where former state senator Mary Gojack of Reno, a former blackjack dealer, defeated a large field of candidates, including her former husband, for the Democratic nomination.

Her GOP opponent is Barbara Vucanovich of Reno, a former aide to Sen. Paul Laxalt.

In the gubernatorial primaries, Gov. Robert List easily won the GOP nomination, while Attorney General Richard Bryan defeated five hopefuls for the Democratic nod. New Hampshire

Two-term Gov. Hugh Gallen (D) had no primary opposition, and his GOP challenger in November appears to be engineering professor John Sununu.

In unofficial returns from all but one precinct, Sununu led state senate President Robert Monier by about 1,700 votes. Monier, however, has asked to have the ballots impounded, and indicated that he might seek a recount.

Adding to the political uncertainty was the last-minute decision Tuesday by former governor Gov. Meldrim A. Thompson Jr. (R) to run in the fall campaign as an independent. Some Republicans said they feared he would play a spoiler's role against the GOP nominee. Rhode Island

Neither three-term Gov. J. Joseph Garrahy (D) nor freshman Sen. John H. Chafee (R) had primary opposition.

Garrahy's Republican challenger is Vincent Marzullo, a one-time Garrahy aide drafted by the GOP to oppose his old boss.

In the Democratic Senate primary, former state attorney general Julius C. Michaelson easily defeated anti-abortion candidate Helen Flynn. Utah

Former speaker of the state house Howard Nielson edged fellow Brigham Young University professor Ray Beckham for the GOP nomination for Utah's newly created 3rd Congressional District. Nielson will be the heavy favorite in November against Independent Henry Huish. The Democrats fielded no candidate in the heavily Republican district.

There were no other contested primaries in the state. Republican Sen. Orrin G. Hatch and his Democratic challenger, Salt Lake City Mayor Ted Wilson, were unopposed in their respective primaries, setting up what is expected to be one of the most closely watched races of the fall campaign. Vermont

Veteran Republican Sen. Robert T. Stafford, a leading environmentalist, fought off a challenge from two conservatives who said he was spending too much time traveling around the world and not enough tending to the state's needs.

Stafford defeated businessman Stewart M. Ledbetter and former White House domestic policy aide John McClaughry.

In the Democratic primary, former state secretary of state James A. Guest, the national president of Consumers Union, defeated nominal opposition. Washington

Despite being outspent 5 to 1 by wealthy Seattle businessman Larry Penberthy, Seattle City Attorney Doug Jewett won the Republican nomination for Senate by a 3-to-2 margin.

Jewett will have his work cut out for him this fall. The Democratic incumbent, Sen. Henry M. Jackson, won 94 percent of the vote over an obscure challenger in his bid for a sixth term. Jackson has a campaign war chest of $2 million for the fall campaign, and has won his last two elections by 72 percent and 82 percent. Wisconsin

Sen. William Proxmire (D-Wis.) easily won renomination, while Rep. Clement J. Zablocki (D-Wis.), chairman of the House Foreign Affairs Committee, turned back his toughest challenge in 34 years, defeating Lynn S. Adelman, a liberal state senator. Proxmire faces Scott McCallum, a Republican state senator, in November.

In the GOP governor's primary to succeed retiring Gov. Lee S. Dreyfus, industrialist Terry Kohler, the son and grandson of Wisconsin governors, defeated conservative Lowell Jackson.

He faces Democrat Anthony Earl, a former majority leader in the state House, who eaked out a victory over former acting governor Martin J. Schreiber. Wyoming

Democratic Gov. Ed Herschler romped to nomination for a third term over rancher Pat McGuire. His Republican opponent in the fall is former state house speaker Warren Morton, who won a three-way race.