The Treasury Department, saying it had effectively run out of money, last night transferred $17 billion out of the Social Security trust fund and two other federal pension accounts to pay the government's bills.

The tapping of the trust funds was described by Treasury officials as a technical bookkeeping transaction that was nonetheless essential to prevent a government-wide financial crisis because of Congress' failure to raise the federal debt ceiling of $1.8 trillion.

Without such action, they said, the Treasury would have been unable to cover the November checks mailed yesterday to 36 million Social Security beneficiaries as well as three million civil service and railroad retirees.

A coalition of elderly and labor groups, including the American Associations of Retired Persons, and five House Democrats charged in a lawsuit late Thursday that Treasury's plan was an illegal raid on the Social Security trust fund and that, by tapping into the fund, Treasury Secretary James A. Baker III was violating his fiduciary duty as its managing trustee.

The suit, filed in U.S. District Court, also contends that the transfer could end up costing the Social Security trust fund $1 billion to $2 billion in lost interest payments over the next five years.

But the plaintiffs failed to win a temporary restraining order to block the Treasury plan. Yesterday, they temporarily backed off pursuing their case because, according to one lawyer, "there is a reluctance on the part of anybody to create a situation where the Social Security beneficiaries would not receive their checks."

The House, led by Democrats, yesterday passed a debt-ceiling extension designed to tide the government over for five days. Shortly after midnight last night -- the administration deadline for extension of the debt ceiling -- the Senate passed its own version of a debt-extension bill, but with alternate language, leaving differences still to be resolved before the measure can be passed.

Normally, the Social Security trust fund is held as a reserve account while actual payments to beneficiaries are made from general Treasury revenue. The Treasury then reimburses itself from monthly Social Security payroll tax receipts with excess tax funds transferred back into the trust fund.

But Treasury says it has been rapidly running out of cash ever since Oct. 1 when the $1.8 trillion debt limit was first hit, thereby requiring it to dip into the Social Security trust fund to make payments to beneficiaries. The Treasury action redeemed or unilateral canceled -- $17 billion in Treasury securities held by the Social Security trust fund, the Civil Service Retirement Fund and the Railroad Retirement Fund.

This action would instantly lower the outstanding federal debt and legally free the Treasury to borrow new money from the public without violating the debt ceiling.

The Treasury actually began to implement this plan earlier in the week when it auctioned off $13 billion in notes and $4.75 billion in 20-year bonds to banks, brokerage firms and other investors. These investors began to write checks to the Treasury yesterday to pay for the securities, thereby refilling the government's empty coffers.

In a statement yesterday, Baker denied any illegality and said that he would "reluctantly" authorize the redemption unless a congressional agreement raising the debt ceiling was reached by midnight.

"I recognize that accelerated redemption of these obligations, while clearly within my legal authority, will disadvantage the trust funds because it will result in a loss of interest to these funds," said Baker. "However, I am prepared to authorize this action in order to assure that all who are scheduled to receive payments from the trust funds are paid so that the federal government does not default."

But it remained unclear yesterday how much Treasury's action will ultimately cost the trust fund. Rep. Jim Jones (D-Okla.), chairman of the Social Security subcommittee and one of the plaintiffs in the lawsuit, contends that the fund will have been reduced to $8 billion.