Mayor Marion Barry was loudly booed yesterday when he made a surprise appearance on the steps of the District Building at a rally of many of his old supporters who were protesting his budget cuts and job layoffs.

His anger boiling over when some 300 demonstrators repeatedly interrupted his speech, Barry glowered at a group of Corrections Department employes, who were at the rally to protest layoffs at the city jail and Lorton reformatory, and said: "Those who have their own private agendas can go to hell!"

"I don't see you booing Senator Leahy, I don't see you booing Congressman Dixon, I don't see you booing those who hold the pursestrings," the mayor declared.

Clearly stung that he was the target of growing community anger over his handling of the city's budget crisis, Barry continued: "I dare you to boo the [D.C. City] Council, I dare you to boo the Congress, because you don't have enough guts to do it."

When he finished his 15-minute speech, Barry strode into a knot of spectators for a series of sometimes angry debates, conducted amid the din of continuing amplified speeches, music at the rally and the jackhammers of a nearby Pennsylvania Avenue reconstruction project.

At one point, a young lawyer for Legal Services for the Elderly, Cheryl Fish, told Barry of criticism of his administration purportedly voiced by John A. Wilson (D-Ward 2), chairman of the council's Finance and Revenue Committee.

"Wilson is full of s---," Barry replied.

Until his anger boiled over in public yesterday, Barry had been simmering over what he views as Wilson's delay in acting on a package of $24 million in new or increased taxes or license fees, mainly on businesses. Bishop Edward H. Moore, master of ceremonies for the rally, repeatedly attacked Wilson for bottling up the measure.

Barry's encounter with his critics came during a rally organized by a new group calling itself the Coalition for Human Dignity. It was formed recently by leaders of municipal unions and beneficiaries of the health, welfare, corrections and recreation programs curtailed by Barry's belt-tightening efforts.

From a small nucleus, the coalition grew to more than 75 organizations and individuals, ranging from the Greater Washington Central Labor Council to such groups as the Statehood Party, the Democratic Socialist Organizing Committee, the Gray Pathers, the Gay Activist Alliance, the D.C. Coalition for Youth and the Citywide Housing Foundation.

As the coalition grew, so did the manifesto for yesterday's rally. It ultimately included not only budget protests but an end to housing speculation and finding alternatives to prison sentences for nonviolent offenders.

Barry's budget-trimming plan for the city envisions a reduction of 1,540 city jobs -- including 403 by layoffs -- cutbacks in Medicaid payments, and the number of recreation centers the city operates.

Most of the dozen speakers yesterday agreed that the city has financial problems, but insisted that Barry had sold out the underprivileged who tormed his constituency as an activist in the 1960s, instead of cutting the city's administrative hierarchy.

"I have a word for our good friend the mayor," William Simons, president of the Washington Teachers Union, declared before Barry arrived at the rally. "He got into office by appealing to those who where on the lower end of the spectrum. I would remind him . . . don't forget that."

"Instead of cutting back, we should be spending more," Simon declared. "We are in for a long hot summer and a lot of bloodshed if [high] unemployment continues."

Donald MacIntyre, vice president of the American Federation of Government Employes, a union that represents Corrections Department employes among others, urged his listeners to "hit the door of every congressman" involved with District financing.

Barry's minister, the Rev. David Eaton of All Souls Unitarian Church, blamed the city's plight largely on the failure of President Carter to push hard enough for financial support for the city. Eaton recalled that Carter once described himself as a proud Washington resident who sent his daughter Amy to public schools.

"That son of a gun who sits in the White House, he needs to be born again for the third time, for the second time didn't help," Eaton said.

Eaton charged that the city's news media were manipulating the public into blaming Barry and the City Council for the city's problems. He declared, "The one who will benefit is the Congress, who can say, 'We told you so.'"

One subtle way this is done, Eaton said, is a frequent reminder in the press that Barry retired the daishikis he wore in his activist days for the three-piece suits he favors as mayor.

Organizers of yesterday's rally had hoped that thousands of Washingtonians would show up, and were frankly disappointed that only about 300 appeared to hear the speeches and to parade along F Street in the heart of the city's retail core.

"It's sure is terrible," said Bernard Demczuk, a union shop steward in the Corrections Department and a rally organizer. "Maybe everybody is mowing their lawn. I don't know. But we're going to continue, to pressure the City Council and Congress."

Within minutes after the rally began, Council Chairman Arrington Dixon arrived. He said he had not been invited, but wanted to speak.

Dixon, like Bary later, was booed when he said city officials were acting responsibly by cutting back some programs. Dixon said he was undaunted by the booeing.

"I'm here to be a responsible leader, not to respond to the crowd," he told reporters.

Barry arrived toward the end of the rally, and explained later that, while he had not really been invited, the rally organizers had suggested he might want to come.

Moore introducing Barry, called on the audience to show respect. "He's our mayor . . . . We have nothing personally against Barry," Moore said.

But booing began immediately.

Barry criticized his listeners for failing to go to Capitol Hill to voice support for a full federal payment to the city and opposition to budget cuts.

"We were there! We were there!" shouted Betsy Finley, director of the Washinton Free Clinic, who sat through two days of hearings recently conducted by Rep. Julian C. Dixon (D-Calif.), the new chairman of the House D.C. Appropriations subcommittee.

Finely was the first to engage Barry in a sidewald debate, insisting that better places than social programs could be found to make budget cuts.

Barry sought to explain his reasoning, saying, "I don't like what I'm doing . . . but if [city] checks bounce, I'll be out of office."

When it was over, Finley walked away, sighing. "It was like talking to a wall," she said.

Steve Young, a burly guard at the D.C. jail, was the next to engage the mayor, telling him: "It's our people's lives that are at stake."

"I don't like it," Barry acknowledged.

When someone suggested that Barry should cut the size of his own office staff and rescind pay increases he gave to several individuals, the mayor declared: "My staff works as hard as you do."

"No, they don't," a woman replied.