A buoyant Edward M. Kennedy returned to Washington last night and said the results of the Maine town caucuses prove that "the majority of the members of the Democratic Party want the president out of the White House to debate."

Kennedy told about 100 chanting, cheering campaign workers who virtually took over an arrival gate at National Airport that his strong second-place finish in Maine made him "confident in New Hampshire and all the other states."

"Four days ago we were 19 points behind President Carter," Kennedy said, referring to a Maine newspaper poll last week, "and tonight we're in a dead heat with him."

Kennedy was speaking just before 10 p.m., when his campaign figures showed him trailing Carter by a narrow margin that had not yet began to widen.

Campaigning in New England during the past two weeks, Kennedy had hit hard at Carter's repeated refusals to take part in any debate with his Democratic challengers. Last night he said that point had obviously sunk in on the voters of Maine.

"The message that goes across this country will be that people . . . are not going to be satisfied with cliches, slogans, radios ads and TV ads. What I saw in the state of Maine were parents that were deeply concerned about whether their children were going to be sent overseas to the Persian Gulf, and they want to hear a debate on the issues of war and peace."

As he left for home, Kennedy told his supporters to "take a look at tomorrow's Boston Globe." The Globe in today's editions, reports that its poll of Massachusetts Democrats shows Kennedy leading Carter there by 62 to 29 percent.

The mood in the Kennedy camp was near despair at the beginning of the day. Although the handshaking, cigar-smoking candidate was outwardly optimistic as he toured three Maine caucuses, his aides said privately that the campaign would be hard-pressed to keep going after another defeat of the magnitude of the Iowa caucuses, where Carter won by nearly 2 to 1.

Tonight, at Boston Garden, the mood changed to optimism tinged with confusion about the actual outcome and some bitterness toward CBS at the early projection of a lopsided Carter victory.

"Give us some results other than CBS," shouted a young Kennedy worker in disgust as he was trying to find out the tally.

Kennedy was cautious in his claims when he appeared early in the evening at a prearranged photo event in which he was endorsed by several Boston professional athletes. But when aides told him during a subsequent fund-raiser that he was doing much better than expected in Maine, the senator returned to the small dressing room where reporters were waiting to tell them he was encouraged by the results.

His aides, if anything, were even more pleased.

"I'm delighted, just delighted," said press secretary Tom Southwick.

The hope of Kennedy and his strategists is that his showing in Maine will encourage his supporters in New Hampshire and enable him to win the Feb. 26 primary there.

The third-place finisher in Maine also said he was pleased with the outcome.

California Gov. Edmund G. (Jerry) Brown Jr. said his showing indicated that the issues he has been stressing, especially opposition to nuclear energy and the draft, are beginning to catch on.

"Both Carter and Kennedy dropped and my campaign gathered strength," Brown said at Logan Airport in Boston, where he was en route back to Sacramento.

However, the Brown campaign is low on funds and a sizeable deficit has been projected by the time of the New Hampshire primary. It is not yet certain whether Brown's showing in Maine was strong enough to improve both his fund-raising and his campaign prospects in New Hampshire.