They were in the same building, supporting the same cause from the same podium. But there was a significant five-minute gap separating President Carter's and Sen. Edward Kennedy's speeches at last night's ERA fund-raiser at the Mazza Gallerie.

"See, the Democratic Party's getting closer and closer and closer. Tonight we're only four or five minutes apart," said Kennedy, who for months has been demanding a debate with Carter.

Carter had been the scheduled speaker for the event, which drew 500 to an earlier White House reception anmd the dinner, which was organized by the National Women's Political Caucus and ERAmerica. Kennedy was invited also, but as a guest.

On Tuesday, however, Kennedy staffers contacted event coordinators and said Kennedy would come if he, too, could address the group. Permission was granted and a hasty invitation to speak also was sent ot John Anderson. Last night, Anderson was campaigning in Pennsylvania but sent spokeswoman Catherine East to punch hit for him.

Ronald Reagan was not invited, according to Kathleen Currie of ERAmerica. "We only invited ERA supporters. He could have come and paid for his dinner," she said.

Earlier, over cocktails in the East Room of the White House, the ERA supporters were optimistic about a potential ERA ratification vote in the Illinois State Legislature. But many clutched their throats and sent shocked stares across the banquet tables when Rep. Robert Drinan (D-Mass.) announced during his invocation that the ratification effort had failed.

"We promise you, O God of justice, that today's defeat in Illinois will not deter us or detain us or discourage us in the pursuit of our goal," said Drinan.

Carter, too, spoke of continuing the fight for ratification at last night's dinner. He told of many defeats he personally had suffered, such as his 1966 bid for governor of Georgia and the 20 years he had to wait before a daughter was born. "We had some disappointments along the way and we did not intend to lose. It's not an easy task," he said. "But there is no reason for us to fail."

Lynda Bird Robb, chair of the President's Advisory Committee on Women, said she, too was disappointed by the vote. "But I am optimist. I know how long it took for my father to get the civil-rights legislation he did. It doesn't come easy."

in his speech, Kennedy hewed close to his normal campaign line, stressing women's issues along with the economy.

Many men were in the audience, including Charles Curry, head of the National Business Council for the ERA, an organization of 120 top business and corporate executives working for passage of the amendment. "The men really stood behind us," said Curry, a businessman from Kansas City. "They really believe in it. We're ashamed for not having dont it sooner."

Standing next to the elevators in the atrium of the Mazza Gallerie, surrounded by shops such as Neiman-Marcus and the new F.A.O. Schwarz, emcee Liz Carpenter said, "Tonight we are here to continue our shopping spree for a little item we missed 200 years ago."

When asked her reaction to the Illinois vote, Carpenter stressed that it was not "devastating. No, it's disgusting. But we know what it is to be faced with petty men with little bits of power."

After his speech, President Carter was presented with a lithograph by cartoonist Cathy Guisewite, creator of the "Cathy" comic strip. The drawing shows the cartoon character in the midst of unkempt apartment lamenting, "What do you mean, I still don't have equal rights??!"