President Carter and Ronald Reagan finally got together tonight at New York's annual Alfred E. (Al) Smith dinner, where Carter delivered a lecture on religious intolerance aimed at some of Reagan's fundamentalist Christian supporters.

With Reagan sitting a few feet away at the head table, the president recalled a question asked him Wednesday at a "town meeting" in Pennsylvania by a 12-year-old Jewish boy who wondered whether God heard his prayers.

The president said that such a question should never have to be asked in the United States of 1980, and added:

"In our zeal to strengthen the moral character of this nation we must not set ourselves up as judges of whom God might hear or whom he would turn away." s

The remarks about tolerance were clearly in reference to the recent controversy over the preaching of one fundamentalist minister that God hears the prayers of only "redeemed" Christias. Reagan, who enjoys the support of a number of fundamentalist Christian organizations, has said he disagrees with that view.

The annual dinner here, which raises money for charities of the Roman Catholic archdiocese of New York, was the first face-to-face Carter and his Republican opponent.

The two shook hands and smiled broadly when the president, who, unlike, Reagan, did not attend the dinner, entered the Waldorf Astoria ballroom just before the speeches were to begin.

The occasion is traditionally one for humerous remarks, but both candidates sought to score political points as they poked fun at each other and themselves.

Carter told Reagan of the "terrible burden" of the presidency, adding, "It's a terrible experience." He also congratulated New York's Cardinal Terence Cooke for having "demonstrated a power even greater than the League of Women Voters" -- a reference to Reagan's refusal so far to meet him in a one-on-one debate.

But then Carter turned to the subject of religious intolerence while praising Smith, a Catholic of humble origins who rose to become governor of New York and the 1928 Democratic presidential nominee.

"My religion is an important part of my life," the president said. "I've studied the Bible all my life. But nowhere in the Bible, Old or New Testament, are there instructions on how to balance the budget or how to choose between the B1 bomber and the air-launched cruise missile. What I do find is 'judge not that ye be not judged' and the commandment to love my neighbor."

Reagan delivered a short, graceful speech that centered on Smith's contribution to religious tolerance.

In contrast to Carter's more topical campaign message, Reagan's speech had both a light and a self-deprecating tone, including two references to one of the 69-year-old Republican's points of political vulnerability -- his age.

Reagan began by telling, in a mock southern dialect, about a mythical conversation in which Carter called him and asked why he looked younger every time there was a picture of him riding a horse.

"I said, 'Well, Jimmy, I just keep riding older horses,'" Reagan said he replied.

Reagan then said there was no truth to the "rumor that I was present at the original Al Smith dinner."

But Reagan also raised a point of the president's political vulnerability -- the hostages in Iran. He said there was now much speculation about a release of the hostages and its likely impact on the election, but added that, regardless of the impact, "No one in America will rejoice more than I when America's long wait for a resolution of this crisis is over."

Reagan hushed the audience and won a long, standing ovation for his concluding tribute to Smith, whom he described as "an organic New Yorker," and "a man of peace, good will and profound faith."

Smith, a reform governor of New York, was the Democratic nominee for president against Herbert Hoover in 1928. Most historians ascribe Smith's defeat to the then-widespread prejudice against having a Catholic in the White House.

Reagan's speech recalled the night of Smith's defeat, when his "hopes of leading the nation had turned to ashes, not because he lacked qualifications, but solely because of religious bigotry."

On that sad election night, Reagan recalled, Smith overcame the bitterness, smiled, and said, in reference to his wife, "This is Katie's birthday, let's go upstairs and cut the cake."

Reagan concluded, "That's what I call real class."

Earlier today, while campaigning in Hempstead, on Long Island, Carter returned to his favorite campaign theme as he accused Reagan of advocating a U.S. response to the Soviet Union's invasion of Afghanistan that he said would have produced "an international threat of war."