Legislation that would guarantee that the federal government would pay for 80 percent of the cost of completing the 101-mile Metro rail system was approved yesterday by the Senate Govermental Affairs Committee.

The $1.7 billion funding measure assures construction of the remaining 41 miles of the system but would require local governments to make up for operating losses.

The bill nearly was sidetracked, however, when Sen. Charles Perry (R-Ill.) tried unsuccessfully to tie its passage to the elimination of one of the most sacred of Capital Hill perks -- free parking for Congress and its employes.

Approval of the funding package by the full Senate could come as early as Saturday, setting the stage for a compromise with the House. The House version differs from the Senate bill in that it includes a $197.7 million subsidy to help Metro make up its operating losses.

Rep. Herbert E. Harris II (D-Va.), a cosponsor of the House-passed bill, said the Senate panel's deletion of the operating subsidy would not block a compromise that would permit the president to sign the bill before the end of the year.

Harris said "the chief objective" of the legislation is to have the federal financing commitment in time for the Virginia and Maryland legislatures to consider how to meet the federal requirement that local jurisdictions must provide "a stable and reliable source" for their 20 percent of the cost. The two legislatures meet in January.

Elimination of the operating subsidy -- which would have been in addition to a 20 percent federal subsidy that already goes to Metro and other city transit systems, could imperil approval in Richmond. Gov. John Dalton has said he considered the extra subsidy "an integral and essential" part of the legislation.

Gov. Harry Hughes has said Maryland is prepared to meet the local-funding requirement by transferring money from the state transportation fund.

The District government, which also must guarantee its share of the cost, has pledged to meet the requirement, most likely by earmarking receipts from an existing tax.

The committee vote was 12 to 2 with both Missouri senators, Democrat Thomas F. Eagleton and Republican John C. Danforth, voting against it. Eagleton sent a letter along with his proxy, saying he could not support "ordering up shiny new rail cars" for Metro that cost up to $1 million each while the transit system in St. Louis "must keep some of its buses' engines running overnight" because it can't afford garages to keep them warm.

Eagleton, who is chairman of the D.C. subcommittee that conducted hearings on the bill, said the $7.2 billion price tag for Metro is more than the combined costs of five other rapid transit systems built or being completed, in Altanta, Baltimore, Buffalo, Miami and San Francisco -Oakland.

Percy's proposal, to impose a fee on the 8,000 free parking spaces on Capitol Hill and on others allotted to Congress and federal judges across the country, was greeted with a barrage of objections.

First, Sen. Charles McC. Mathias (R-Md.) said tacking the amendment on the Metro bill would imperil its passage. So Percy agreed to withdraw it and put it on another bill before the committee yesterday, the National Energy Policy Act.

Then Sen. John Glenn (D-Ohio) said Percy should wait to see how many federal workers switched to Metro as a result if the executive order by President Carter that imposed half-rate parking charges on 2 million executive branch workers, beginning Nov. 1.

(A Metro spokesman said later that "no dramatic changes" in ridership have been detected since Nov. 1 that could be attributed to the new parking fees at federal agencies. Average weekday ridership is about 275,000; 75,000 on Saturdays, 65,000 on Sundays.)

Next, Mathias tried to amend Percy's amendment to exempt car and van pools. But Mathias' idea was laughed down by Percy, who said Mathias' amendment had "a giant loophole, one big enough to drive a van through," because it did not require a minimum number of passengers for a pool. t

About that time, Sen. Jacob Javits (R-N.Y.) told Percy that "I love you, Chuck, and you're a great saleman," but he thought Percy was "rushing us a bit." Javits called for a postponement.

Sen. Abraham A. Ribicoff (D-Conn.), the committee chairman, told Percy that Sen. Claiborne Pell, chairman of the Senate Rules and Admination Committee, wanted Percy's proposal transferred to his committee.

Percy fought that off, saying "Rules has had plenty of time to consider this if they had any real interest. This is just another way of delaying or killing it."

Throughout the 1 1/2-hour debate, Percy challenged his colleagues to "face up to this problem." He said "it's absolutely ludicrous" to talk about energy conservation while retaining free parking for themselves, and even adding 406 more spaces upon conpletion of the Hart Senate Office Building.

Percy got lip-service support from several committee members, but only Sen. David F. Durenberger (R-Minn.) appeared ready to vote yesterday to take away the free parking on the Hill.

When it became obvious, as Danforth observed, that Percy "just doesen't have the votes," Percy agreed to postpone action on the proposal until Thursday.

"If he can get a quorum," quipped one of the staffers who, along with some reporters covering the hearing are among those whose free parking spaces are imperiled by Percy.