Walter F. Mondale, setting the stage for Sunday's presidential debate on foreign policy, accused President Reagan today of having "a naive and primitive notion of national strength."

In response to Reagan's accusation yesterday that he is a threat to national security, Mondale said such attacks are in keeping with a 30-year record of "profound confusion" that had led Reagan to launch similar blasts at past presidents, Democratic and Republican.

"For more than a generation he has gone around the country saying that everyone in power would weaken America," the Democratic presidential nominee told a cheering crowd of 1,700 students at Stanford University.

Mondale said Reagan called President John F. Kennedy weak for not taking "what he Reagan called the final step in Cuba," called President Lyndon B. Johnson weak for "not threatening the use of atomic bombs in Vietnam," accused President Gerald R. Ford of "bowing and scraping" before the Soviet Union and criticized President Richard M. Nixon for signing the SALT I and the anti-ballistic missile ABM treaties.

Reagan's misguided notion of strength led him to station Marines in Beirut "in a vulnerable spot against the advice of the joint chiefs of staff" and to proclaim that U.S. intelligence was weak, "practically an open invitation to terrorism," Mondale said.

It also led Reagan to buy unneeded MX missiles and "deploy them like sitting ducks" and to spend $25 billion on a B1 bomber that "the Soviets have spent 15 years preparing to shoot down," he said.

In one of his toughest foreign policy addresses of the campaign, Mondale also accused Reagan of failing to master the essential facts of arms control and nuclear weaponry and cited the observation of Reagan's first secretary of state, Alexander M. Haig Jr., that the White House was a "ghost ship."

"It may be 2:30 in the morning," Mondale said. "He the president may be awakened to hear that missiles are on their way. He may be asked to make, within a minute or two or three, the most fateful choice in human history. At a moment like that, we have a right to demand a president who knows the crucial facts that he must know.

". . . Mr. Reagan may think he can recall a missile the way he can roll a movie reel in reverse, but it just ain't so," Mondale said.

Mondale declined to speculate on why Reagan has not mastered such facts, but Sen. Gary Hart (D-Colo.), who accompanied Mondale during the California swing, was far less reticent.

Meeting reporters, Hart delivered some of the sharpest personal attacks directed at the president during the campaign.

"I just don't think his gears are meshing," Hart said of Reagan's performance in the first debate Oct. 7. "It's either age or fatigue, and it can't be fatigue because he's only worked four hours a day for the past four years."

Hart also said comments by Reagan aides that the president had been "brutalized" by the predebate briefing process raised "a new wimp factor. If his own staff can brutalize him, think of what Soviet Foreign Minister Andrei A. Gromyko can do."

While Mondale would not be goaded into such direct attacks on Reagan today, he unleashed a blistering assault on Vice President Bush. He called Bush a "political hit-and-run driver . . . who doesn't have the manhood to apologize" for his accusation in last Thursday's debate that Mondale had said U.S. servicemen in Beirut had "died in shame."

"George, apologize," Mondale said. "Get it over with. Stop embarrassing yourself this way."

Bush had said Monday that his accusation was based on Mondale's comments that the suicide car-bombing in Lebanon had "humiliated" America. But Mondale said: "He's dead wrong." He said those remarks referred to administration policy rather than to the valor of soldiers in Lebanon.

In response to a question, Mondale declined to say that he thinks Reagan "incapable" of mastering details of arms control. Instead, he ridiculed Reagan's past misstatements about weapons systems.

Although Reagan has never lost an election in California, Mondale predicted that the Democratic ticket will win here.