President Reagan and Walter F. Mondale staked out sharply contrasting positions on a wide array of foreign policy issues tonight in a nationally televised debate that ranged from Central America and Lebanon to arms control and presidential decision-making.

Throughout the 90-minute debate Mondale repeatedly questioned Reagan's competence and leadership in dealing with foreign affairs. He said that Reagan has insufficient knowledge about weapons systems, and he castigated Reagan for permitting publication of a CIA-sponsored manual that appeared to promote assassination and terrrorist tactics in Nicaragua.

"The president's called the commander in chief," Mondale asserted. "He's called that because he's supposed to be in charge."

Reagan, braced for these charges, denied them all. He disputed Mondale's accusations on arms control, denied that his administration condoned publication of the controversial sections of the pamphlet, defended his decisions in Lebanon and said, "I know it will come as a surprise to Mr. Mondale, but I am in charge."

The one surprise of the debate, which appeared to catch Mondale off guard, came when Reagan was asked whether he was too old to meet the demands of the presidency in a crisis, a question raised by Reagan's performance in the closing stages of their first debate.

Reagan, 73, said with a grin that he is not too old and doesn't plan to make an issue of age. Then he said, "I am not going to exploit my opponent's youth and inexperience, not at all."

Mondale, 56, joined in the laughter.

Throughout the debate, Mondale argued that Reagan has escalated the "madness" of the arms race and failed to negotiate seriously with his Soviet counterparts. At the same time he appeared to bid for the support of defense-minded voters who may have responded to Reagan's charge that Mondale does not understand the Soviet threat.

Mondale said that it was Reagan who was gambling with national security with his proposal to share space defense technology with the Soviets. He also criticized Reagan for the failure of the United States to retaliate against terrorists in Lebanon.

Citing the three attacks against U.S. installations in Beirut and the administration's failure to carry out its threat to retaliate, Mondale said, "The terrorists have won each time."

But Reagan reasserted his criticism of Mondale's defense record, saying that "he has a record of weakness . . . that is second to none."

Reagan insisted that he has made peace a high priority and has submitted far-reaching proposals to rid the world of nuclear weapons. He also said the U.S. defense buildup would, in a second term, persuade the Soviets to negotiate seriously.

The two candidates talked emotionally of the merits of defensive space weapons systems. Reagan said it would be "better to destroy weapons than humans," and Mondale called the president's idea of developing a defensive system, demonstrating it to the Soviets and sharing it with them a "dangerous" proposal.

Mondale said that the administration's lack of a clear mission in Lebanon, its failure to heed intelligence warning of terrorist attacks and its unfulfilled threats of retaliation had humiliated the United States in the Middle East.

Reagan responded that the multilateral peace mission in which the United States participated had been succeeding, which, he said, is why the terrorists struck. He emphasized that suicide attacks such as the one that killed 241 servicemen on Oct. 23, 1983, were difficult to prevent.

At one point Reagan turned to Mondale and said quietly, "I am tempted to ask what you would do."

Mondale charged that the administration has eroded moral authority by cozying up to dictators throughout the world and by attempting to topple the Nicaraguan government through covert action.

Reagan defended his record, saying that in its own interests, the administration must deal with governments with imperfect human rights records.

"The invasion of Afghanistan did not take place on our watch, neither did Iran," Reagan said. "We have done our best to see human rights are extended."

Although the debate was supposed to be limited to foreign policy and national defense, both candidates turned their closing statements into speeches summarizing their favorite campaign themes.

"I will keep us strong, but strength also requires wisdom and smarts in its exercise," Mondale said. "The president must know essential facts and have a vision of where the nation will go . . . . It's time for America to provide new leadership."

Reagan never finished his closing statement because moderator Edwin Newman stopped him under the rules after it had run the allotted four minutes. Reagan was interrupted while he was telling a story about what he would put in a time capsule for people to read 100 years from now.

Reagan did have time to repeat his basic campaign themes of "economic expansion, freedom and peace," and he said, "I seek reelection because I want more than anything to complete the new beginning we charted four years ago."

The debate was held in the Music Hall in the Kansas City Municipal Auditorium. The panelists were Georgie Anne Geyer, a syndicated columnist for Universal Press Syndicate; Henry Trewhitt of The Baltimore Sun; Morton M. Kondracke of The New Republic, and Marvin Kalb of NBC News.

The first question dealt with Central America, but Mondale launched into a tour of the foreign policy horizon -- from Central America to Lebanon to arms negotiations -- to argue that the president is not in full command of the facts.

Mondale said the disclosure of a CIA manual instructing Nicaraguan "contras" in the fine points of political assassination had undermined the moral authority of the countries in that region and had "strengthened our enemies."

"I don't know which is worse, not knowing of the manual , or knowing and not stopping it," he said.

Reagan responded that the CIA manual had been prepared by a contract employe in the region, and that his superiors, once they saw the passages related to assassination and other forms of political terrorism, ordered that they be excised. He said his administration is investigating why some manuals with the offending passages were printed, and that once the person responsible is found, "we will take appropriate" steps.

Reagan showed a flash of anger and incredulity when Mondale repeated his charge that the president had once said that missiles launched from submarines could be recalled.

"How anyone could think any sane person could believe you could recall nuclear missiles, I think is ridiculous," Reagan said.

Reagan and Mondale clashed sharply on national defense and U.S.-Soviet relationships in answer to the second round of questions.

Calling attention to a Mondale commercial in which the Democratic candidate stands on the deck of the aircraft carrier USS Nimitz looking at F14 jets, Reagan said, "If he had his way, he'd be standing deep in the water" because Mondale had opposed the F14, the Nimitz, the M1 tank, the B1 bomber and other weapons systems.

"He has a record of weakness in regard to our military defense that is second to none," Reagan said.

Mondale replied, looking directly at Reagan, "Mr. President, I accept your commitment to peace, but I want you to accept my commitment to national defense."

He said he had opposed the F14 because of problems in its development and would propose defense budget increases as president.

Reagan charged that "unilateral disarmament" had occurred under his predecessors while the Soviets had engaged "in the biggest military buildup in mankind."

He said he had no apology for using strong rhetoric against the Soviet Union, but that he would work for peace because together the two superpowers could "destory the world or could save it."

Mondale, denying that he ever favored unilateral disarmament, said he would pursue a realistic policy against the Soviets, who he considered "a tough and ruthless adversary."

"But we must meet on the common ground of survival," he said.

A question about the U.S. role in Lebanon drew one of the sharpest exchanges of the evening.

Reagan was asked if he agreed with the view that the United States was forced to leave Beirut in failure. "I have no apologies for our going in on a peace mission," he said.

Reagan added that terrorist acts directed at U.S. personnel were initiated because "we were succeeding" in removing 13,000 of the Palestine Liberation Organization terrorists from Beirut.

Mondale responded with a line from Groucho Marx, who said, "Who do you believe -- me or your own eyes?" Mondale said the American people could see with their own eyes a president who had had ample warning of terrorist attacks, who last fall had received advice from the Joint Chiefs of Staff to remove the Marines from their compound at the Beirut International Airport, and yet who failed to take the necessary steps.

Reagan, in rebuttal, said to Mondale: "I am tempted to ask what you would do." He said the fact that the terrorists were suicidal -- "they think they are going to paradise for perpetrating such acts" -- made it difficult to guard against them. Mondale said Reagan's vow to retaliate against terrorism went unheeded.

On the age question, Mondale agreed that Reagan's age is not an issue. He said the issue instead is one of leadership.

"A president has to lead his government or it won't be done," Mondale said.

He repeatedly scored Reagan for failing to make any progress in arms control with the Soviets and quoted from a book, "Deadly Gambits" by Strobe Talbott, which finds that Reagan lacked basic information about weapons systems.

"Good intentions, I grant, but it takes more than that," Mondale said. "You must be tough and smart."

Mondale dodged a question about Jesse L. Jackson's diplomatic efforts in Central America and Cuba, saying Jackson was an independent person and instead asking Reagan to apologize for Vice President Bush's remarks charging that Mondale had said Americans had "died in shame" in Lebanon.

Reagan did not respond to the call for an apology, but said, "I know it will come as a surprise to Mr. Mondale, but I am in charge."

A question on immigration drew a sharp difference between the two over whether to clamp down on illegal aliens by making it illegal for employers to hire them.

Mondale said he opposes employer sanctions because this would place employers in the position of determining who is a citizen, and would lead to discrimination against Hispanics and others.

He also denied that he was kowtowing to Hispanic leadership groups, noting polls that show a majority of Hispanics favor such sanctions. "Despite the politics of it, I stand where I stand," Mondale said. "I do not want to undermine the liberties of our people."

Mondale said he favors strengthening enforcement efforts along the U.S.-Mexican border and working to improve the economies of countries south of the border.

Reagan said he supports the version of the Simpson-Mazzoli bill adopted by the Senate. It called for both employer sanctions and an amnesty for illegal aliens who have lived in the United States for a specified number of years. He said sanctions are necessary to clamp down on employers who bring illegal aliens across the border and pay them "starvation wages."

Mondale blamed some of Central America's economic woes on high deficits, leading Reagan to respond, "I have heard the national debt blamed for a lot of things, but not for illegal immigration across the border. It has nothing to do with it."

Reagan and Mondale clashed on the merits of developing a defensive system, dubbed "Star Wars" by its critics, that could destroy missiles in flight. The original presidential proposal was for long-term research into a system that would use either ground-based or space-based systems.

"Wouldn't it be far more humanitarian to say that we can defend against a nuclear war by destroying weapons rather than slaughtering millions of people?" Reagan asked.

Reagan said it would be better to develop a weapon that "renders those missiles obsolete." Asked whether he would share this technology with the Soviets as he originally proposed, Reagan replied, "Why not? Why not sit down and get rid of all these weapons and free us from this offensive threat . . . . What is wrong with that?"

Mondale said he sharply disagrees with this "dangerous" idea of sharing the most advanced U.S. technology with the Soviets.

"The thought that we would share with the Soviets is a total non-starter," he said.

Instead, he said, the United States should move immediately to negotiate a ban on weapons in space.

"Why don't we stop this now and draw a line to keep the heavens safe from war?" Mondale asked.

Reagan, who said earlier in the debate that "a nuclear war can never be won and must never be fought," said that Mondale's opposition to a defensive system amounted to support for "MAD -- mutual assured destruction."

He said he favors something "that would destroy weapons and not humans."

Mondale said that Reagan's proposal was "a dream" and that it is important to decide between generalizations "and reality."

Mondale was asked if his opposition to the MX missile and B1 bomber wasn't tantamount to giving away half the store before negotiating with the Soviets. He responded that the United States already has a "wide range of technology and weaponry" that gives it all the bargaining chips it needs.

He said he opposes the MX because its basing mode would make it a "sitting duck" and the B1 because the Soviets have been devising ways to shoot it down for the past 15 years. He said he advocates the building of the Stealth bomber system, which, he said, would be able to frustrate Soviet radar.

Reagan defended his support for President Ferdinand Marcos of the Philippines, saying that "things do not look good to us from the standpoint of human rights, but the alternative is a large communist movement.