The House, showing both generosity and skepticism toward the District of Columbia, voted by a wide margin yesterday to give a financial transfusion to the city's troubled pension programs and then voted by a razor-thin margin to keep the convention center project alive.

Both tallies surprised House leaders who had expected more trouble in granting $769 million in federal funds to the pension programs and little difficulty in winning approval for the bill to finance the convention center along with all other construction projects.

The vote on the pension program was 348 to 21. The vote on the convention center was 196 to 187.

Yesterday's vote on pensions is viewed by city and congressional leaders as a step toward assuring future financial solvency for the city.

The existing pension programs mandated by Congress for police, firefighters, teachers and judges owe more than $2 billion in future benefits, but no fund has been created from which the payments must be made. The money now cones out of annual operating funds. Yesterday's action leads toward creating a federally subsidized pension fund.

The convention center vote left the project alive, and should permit the city to finance other public works projects without interruption.

Neither of yesterday's actions was final.

Both bills now go to the Senate, where the pension measure will await a final decision next year. But prompt Senate agreement with the House version of the financing bill - which empowes the city to borrow construction mondy from the U.S. Treasury - could be decisive in determining the fate of the convention center.

Rep. Robert E. Bauman (R-Md.), a third-term consevative whose move yesterday came within nine votes of sidetracking the convention center, told a reporter the project's schances of final approval this year are dead.

Not so, esponded Rep. William H. Natcher (D-Ky.), the 13-term chairman of the House District Apporpiatios Subcommittee, who said the approval reflected the "true attitude of the House."

Mayor Walter E. Washington applauded the pension vote, saying the measure "is loing to get us on a far more credible position in regard to (city) finances." He said he was pleased at the House decision to grant the Treasury borrowing power. "It takes us one step closer to where we want to go," Washington said.

Yesterday's sequece of events addee new complications to already complex and confusing parliamentary situation surrounding the convention enter.

After a separate vote on the convention center the borrowing power itself was approved by a second and final vote of 266 to 119.

That action does not automatically restore the convention center to the appropriation bill. A separate, affirmative action on that is still necessary, perhaps by a joint conference between the House and Senate.

A Senate staff aide said the thin margin by which the convention center won approval in the House yesterday strengthens the hand of the project's foes in the Senate, both on the Senate floor and in conference deliberations.

The project, which would be located on a three-blocked site near Mount Vernon Square, a rundown area north of downtown Washington, would cost an estimated $110 million.

District officials asked Congress this year to appropriate $27 million of start costs as part of the city's budret bil. The House agreed to do so, but the Senate Appropriations Committee has omitted the funds in its version of the bill, whcih will soon reach the Senate floor.

When the budget hill was being adopted in the House nearly two weeks ago, Bauman raised a point of order that knocked out the source of the money for the convention center appropriation - a loan from the Treasury.

That made it important for supporterfx of the convention center to win passage of related bill yesterday renewing the city's right to borrow from the Treasury for all its public works projects for two more years.

The Treasury borrowing authorization bill has been on the House calendar since May, and has been side-tracked at least twice to make way for national legislation. Congressional staff aides say the convention center would not be in as deep peril today if that bill had been passed earlier. Until Bauman's recent challenge, the measure was not regarded as controversial.

The District has been financing public works with Treasury loans for nearly a century.

With the arrival of limited home rule in 1975, it was contemplated that the city would switch over to selling municipal bonds on the open market as other cities do.

Congress, worried about the city's shaky financial situation, insisted that the sale of bonds be delayed until after an audit of the District's books, which is now under way.

House District Committee members, in describing the Treasury borrowing measure as debate opened yesterday stressed that the bill is necessary to finance a wide range of city programs - schools, water supply, sewers, bridge repairs and fire department modernization.

The city plans to spend $92 million on these projects during the 1978 fiscal year, which begins next Saturday.

There was no hint in advance that the final vote on the bill would be so close.

Bauman, who was the only speaker against the convention center, contended the project may prove itself a financial white elephant that the nation's taxpayers would have to bail out.

Natcher relied that the city has a good record in paying back its debts to the Treasury, and that only the District was taking any risk.

He was supported by House Majority Leader Jim Wright (D-Tex.), who cast the issue as a test of home rule. "It would seem petty and petulant to interpose our judgment" over that of Washington's City Council, which voted for the project, Wright said.

Bauman insisted, however, that the House should vote on his proposal that Congress must authorize the convention center by separate legislation before any Treasury loan money could be spent on it. If approved, that would have killed the center for his year, at least.

Almost from the moment the House's electronic voting machine was turned on, it was clear that Bauman's motion had a good chance of passage. It was leading until a bare three seconds before the 15-minute voting period ended, when the tide turned.

Among Washington area legislators, Bauman was supported by Reps. Gladys N. Spellman (D-Md.) and Marjorie S. Holt (R-Md.) and opposed by Reps. Newton I. Steers Jr. (R-Md.), Joseph L. Fisher (D-Va.) and Herbert E. Harris (D-Va.).

Nobody spoke against the pension bill, and its sponsors ranged from Bauman on thepolitical right to Rep. Carter endorsed the principle of the bill last week.

Dellums and Reps. Stewart L. McKinney (R-Conn.) and Romano L. Mazzoli (D-Ky.) reminded the House that Congress created the unfunded pension programs and insisted that the city pay for them. It was only justice, they said, that the federal government subsidize the funds to bring them into actuarial balance.

The $769 million in federal payments would be expended over a 25-year period.

The pension measure makes changes in operation of the funds for the police, fire fighters, teachers and judges. Other D.C. employees are covered by the federal civil service pension program.