When the Chicago Housing Authority ran out of money last winter, federal officials decided it was time to cut off the funds.

The Department of Housing and Urban Development was upset at reports that a third of the elevators in the high-rise projects were broken at any time, that skilled craftsmen were getting $20 an hour to fix toilets and replace light bulbs, and that the patronage-ridden agency had sunk $38 million into debt.

So HUD refused to provide any more aid unless the local agency slashed expenses, fired its board of directors, named a watchdog commission and got rid of its controversial chairman, Charles R. Swibel, a top fund-raiser for Mayor Jane Byrne.

Six months later, Byrne has replaced Swibel with an inexperienced young aide from her campaign, named an oversight panel full of people with close ties to City Hall, and simply ignored most of the rest of HUD's demands. And the federal money is flowing once again.

Chicago is a prime example of the massive problems now facing many big-city public housing authorities, and the difficulties HUD has in doing much about it. The buildings are old, dirty, poorly insulated and clustered in crime-ridden neighborhoods. Vacant apartments often stay empty for months. At least two dozen local housing agencies are in dire financial straits.

For years, the federal government expected these projects to pay their own way with income from both poor and middle-class tenants. But as more welfare families moved in, their meager rents could no longer keep pace with soaring cost of heating and repairing the run-down buildings. Instead, Washington has had to come to the rescue with more than $1.2 billion a year in operating subsidies. The subsidies, along with a great array of other housing programs for the poor and middle class, are one of the large and growing drains on the federal budget.

The Reagan administration is now considering a proposal that would limit these growing subsidies by requiring that the projects be run more efficiently. The plan could force 200 large housing authorities to cut expenses by 10 percent or more.

In the case of Chicago, HUD was forced to resort to its one major weapon -- the threat of a cutoff in funds. Chicago officials responded that if the subsidies were withheld, the city's 140,000 public housing tenants -- HUD's beneficiaries -- would be the victims.

HUD undersecretary Donald I. Hovde insists that his approach to the Chicago Housing Authority (CHA) already is paying dividends. "We are seeing and have seen tremendous progress being made," he said.

But one official involved in the dispute said HUD had backed down on many of the key issues. "The federal government has lost its credibility now," he said. "For HUD to threaten to withhold money again will just start everyone in Chicago laughing hilariously."

The problems came to a head last year when the CHA, unable to meet its payroll, asked HUD for a $49 million bailout. "It was a crisis situation," Hovde said. "Nobody here had a handle on it, quite frankly."

Hovde made Byrne an offer she couldn't refuse: HUD would lend her a third of the money if she allowed a team of outside experts to investigate the CHA. It was a sensitive issue for Byrne, who briefly moved into Cabrini-Green Apartments last year to demonstrate her concern for public housing, and she reluctantly agreed to abide by the team's findings.

HUD's study team, headed by New York housing expert Oscar Newman, concluded that the housing authority was "in a state of profound confusion and disarray." The report said that:

* Chicago's housing projects cost more to run than any other in the country except New York's -- an average of $2,860 a year for each apartment. Although Washington and other cities are not far behind, Chicago needs a higher HUD subsidy than even New York to stay afloat. More than 80 percent of the families in some projects are on welfare.

* The main purpose of the authority is "the acquisition of as many federal government dollars as possible for the creation of patronage jobs and financial opportunities." All but five of the 19 project managers were said to be so incompetent they had no idea how much money was in their budgets.

* The elevator program is in "total chaos," costing CHA $18,000 a year to keep each elevator running, or 4 1/2 times as much as New York. In one five-month stretch, elevator repairmen charged the CHA for up to 100 hours of overtime a week.

* All the apartments are overheated to 80 to 85 degrees round the clock, including boarded-up units. More than half the trash compactors and dumpsters need repairs, causing widespread roach infestation.

The team's most important recommendation was that Swibel, a real estate developer who has run the CHA almost single-handedly for 19 years, resign as chairman.

"Charlie turned this into a personal fiefdom, taking care of unions, favored contractors and providing jobs for the Democratic machine," said Renault Robinson, a dissident CHA board member. "Whoever gets contracts, they contribute to the mayor's kitty. You wanted a contract, you called Charlie and he arranged it."

Hovde called the CHA "a disgrace" and threatened to withhold the next subsidy payment unless Byrne cleaned house at the CHA. Swibel angrily vowed not to resign. The mayor accused Hovde of "sheer bullyism" and charged that HUD was trying to abandon public housing.

Above all, Byrne was determined not to lose Swibel, who helped her take in more than $1 million last year at a single fund-raising party. The urbane Swibel is part of Byrne's inner circle, settling strikes late at night and riding with the mayor in her limousine.

As the pressure mounted, Byrne devised a face-saving compromise by changing the unpaid chairman's post to a full-time job. Rather than abandon his lucrative real estate business, Swibel promptly quit and checked into the hospital with an ulcer.

"They made me the target," Swibel said over a recent lunch at the members-only Barclay Club. "It was easy. They didn't want to attack Byrne directly, so they portrayed me as being close to her and the Democrats. But I didn't want to resign until they brought charges."

Swibel has been embroiled in controversy for years. In one case, a company that later got a CHA contract was found to have installed a free burglar alarm system at Swibel's home, according to the Chicago papers. In another, CHA was keeping millions of dollars in a low-interest account at an Illinois bank that also was paying Swibel's management firm to run an apartment and office complex. And most recently, CHA gave a large insurance contract without bidding to a firm run by his wife's cousin.

On this last incident, Swibel said: "We couldn't get any insurance and I asked him for a favor. I give you my word -- he did me a favor."

Swibel said that HUD repeatedly ignored his requests for more repair money. "What changes can be brought about without money? How can you fix the elevators and paint the apartments without getting an appropriation? HUD approved these cost overruns. They approved every expenditure every year, even for toilet paper."

Although the HUD study had criticized CHA executive director Andrew Mooney, a former Byrne aide at City Hall, for having little experience in housing, the mayor elevated him in August to the $72,000 chairman's job.

Mooney, a bright and aggressive former schoolteacher, said it is important to have "a generalist" heading the CHA. He insisted that the charge about patronage hiring at CHA's 2,200-member staff is one of the many "fallacies" in the HUD report.

Nevertheless, Mooney said he has replaced half the managers at the CHA, which he called "a 50-year-old bureaucracy that hasn't been reorganized since the day it started." He also said he has reduced the deficit to $20 million, cutting purchases by a third, cracking down on union overtime and firing 300 craftsmen and 100 office workers.

"We did have a rather bloated budget," Mooney said. "All these steps should have been taken a long time ago."

Critics say that Mooney still defers to his predecessor on even minor matters. "Swibel is no longer sitting there in the flesh, but he still runs the agency by telephone," said board member Robinson.

Other officials say that Mooney has ignored recent directives from HUD to require competitive bidding and return $44 million in repair money that has been sitting in the bank for months. "It's basically been business as usual at CHA," one said.

Few residents would disagree. At Cabrini-Green, for example, the roofs still leak, some of the narrow hallways are still without lights and the trash chutes are still clogged to the brim with rotten food and beer cans.

"The maintenance is sort of slow because of the people they've laid off," said Markusree Nichols, who lives with her husband, Ulysses, in a three-bedroom unit for $38 a month. "The mayor is responsible for 80 percent of it. She lived here, she knows the conditions. I think that was just for publicity."

Byrne angered many black voters when she added two more white members to the CHA board, tipping the majority from black to white. Soon afterward, she preempted HUD officials by announcing her own CHA oversight committee before they could object.

The panel quickly rushed to CHA's defense, calling the HUD report "one of the most destructive, biased and unprofessional reports which we had ever read."

HUD's Hovde defended the study, but said he now has "a close working relationship" with Mooney and other CHA officials.