House members voted themselves a 7 percent pay raise yesterday, then lost their nerve and defeated the legislation to which the raise was attached.

The first vote was an easy 156 to 64 in favor of the raise, thanks mainly to an artful maneuver by House leaders that allowed members to vote anonymously.

But the leaders could not withstand demands for a recorded vote. And when forced to sign their names to their votes, the legislators defeated the legislation, 219 to 191.

House members were not the only ones affected by yesterday's action. Also involved were the 100 senators, 913 federal judges and about 22,000 others in all three branches of government who make more than $47,500 a year.

But yesterday's votes are unlikely to be the last on the pay raise question.

Under existing law, all members of Congress, federal judges and other federal employees over the $47,500 mark will automatically get 12.9 per cent cost-of-living raises Oct. 1, unless Congress intervenes. Congress is almost sure to intervene, for fear of what the voters would think of that large an increase.

It is virtually certain that amendments will be offered to the forthcoming legislative appropriations bill limiting the Oct. 1 raise to some figure less than 12.9 percent or dropping it entirely. The legislative money bill has already been beaten once this year because of the pay raise issue.

The legislation to which the raise was briefly attached yesterday was a continuing resolution, extending funding at existing levels for agencies Congress will not have freshly funded by Oct. 1, when next fiscal year begins.

To keep the vote nameless, leaders had to hold a quorum of 218 members on the floor and make sure that fewer than 44 asked for a record vote. They succeeded the first time; only 34 asked. But on the second vote they failed.

Arguing against the raise, Gerald B. Solomon (R-N.Y.) said Congress collectively did not deserve one because it has not dealt with problems such as energy and inflation.

Congress consistently votes for more spending, Solomon said; "we are the cause of rampant inflation and here we sit considering a pay raise for ourselves."

But Republican Whip Robert Michel (Ill) said Congress has not had a raise since 1977. "There has been a 20 percent inflation rate since that time . . . eventually we have to face the music and consider what we think we're worth."

After the defeat of the bill, an angry Don Young (R-Alaska) took the floor and said, "I'm getting tired of this body weasling around demeaning itself. If you don't think you are worth more money, get out of the House."

But Millicent Fenwick (R-NJ). said the House demeans itself by the "pickpocket way" it attempts to vote raises. "We justify the contempt people have for Congress," she said.

In 1977, the pay of members of Congress was raised to $57,500, upon a recommendation made by an impartial commission. Since that time Congress has turned down the automatic October cost-of-living increases for itself and other high paid officials. If the 7 percent pay raise had been accepted yesterday, it would have boosted their pay by $4,125, to $61,625.

From the Washington area, Gladys Spellman (D-Md.) voted against the bill, while Michael Barnes (D-Md.) and Democrats Joseph Fisher and Herb Harris of Virginia voted for it.