The legislative strategy that dealt a grave blow to President Reagan's hopes for overhauling the tax code yesterday was the brainchild of the House Republican leadership, staunch Reagan loyalists on most issues but saboteurs on this one.

Their strategy was born in a huddle at the back of the House chamber only two hours before the first vote. The key plotters were House Minority Leader Robert H. Michel (R-Ill.); whip Trent Lott (R-Miss.); Lott's deputy, Rep. Tom Loeffler (R-Tex.), and Reps. Dick Cheney (R-Wyo.) and Jack Kemp (R-N.Y.).

Although Democrats were believed strongly behind the tax-revision bill, the GOP leaders watched one Democrat after another rise to complain about the "rule" reported out by the Rules Committee that was to govern debate on the tax proposal. The unhappy Democrats complained that, under the rule, they would have no chance to vote on an amendment they favored to restore tax benefits to the pensions of public employes.

"We really hadn't focused on defeating the rule until that moment," said Rep. Newt Gingrich (R-Ga.), who was also part of the original huddle. "It suddenly hit us at 10:30 a.m. , if we push hard enough, we can defeat tax-overhaul before we thought we could. We could defeat the rule and keep the bill from even coming up.

"We were watching all those Democrats, and suddenly we were all just looking at each other and saying 'Hmmmmm,' " Gingrich said.

The Republican leadership, which Monday had briefly considered trying to vote down the rule, immediately sent "whip calls" to every Republican member -- instructions to vote down the rule as a matter of loyalty to the leadership. Under House procedures, no bill can be voted on until the rule governing its debate has been approved.

Two hours later, the rule was dead, defeated 223 to 202, with all but 14 Republicans voting no, leaving Reagan's tax-overhaul initiative near political death. The 164 Republican "no" votes, combined with 59 from Democrats, represented a stunning defiance of the president, who had urged all House Republicans to support the bill.

The Republican leadership managed to undermine the president's tax crusade by making the key vote the procedural one on the rule. This allowed Republican members to express their strongly negative sentiments on the tax bill written in the Democratic-controlled Ways and Means Committee without directly taking on the president or even technically voting against tax reform.

"How many of you in your heart of hearts just want this issue to go away?" Lott said to loud cheers from both Republicans and Democrats on the House floor during debate on the rule. "How many times do we have to get burned?"

With the political cover provided by an apparently procedural vote, midwesterners could vote "no" to signal concern over the loss of tax benefits for steel and other basic industries; southwesterners, over oil; Pacific northwesterners, over timber; Washington-area members, over federal workers.

Even members who said they plan to vote for the bill on its merits joined the naysayers on the rule. So did dozens who said they remained undecided about the bill itself.

"I support the bill, but I voted 'no' in good conscience because there are certain things I'm dissatisfied with," said Rep. Paul B. Henry (R-Mich.), referring to concerns of machine-tool manufacturers in his district. "In my view, this was a positioning vote, a chance to show who has concerns. I thought of it as just sending up a flag."

"Also, I'm a Republican freshman. At this stage, you're still trying to make your mark and build relations. I wanted to support my leadership," Henry said.

Several Republicans said privately -- and Democrats publicly -- that Reagan himself was responsible for the setback. GOP members said in interviews that he seemed less than committed to the measure authored by the Ways and Means Committee, making fewer than a dozen calls to lobby House Republicans and not even mentioning the rule vote to them.

"The problem is we got a president who campaigned like Superman and lobbies like Clark Kent," said Christopher Matthews, spokesman for House Speaker Thomas P. (Tip) O'Neill Jr. (D-Mass.).

When Reagan met with six Republicans at the White House two hours after the House vote, he did not mention the rules vote but rather urged them to support the bill, according to those present. Henry, one of the six, said he spoke up: "Mr. President, it's beginning to look like the rule is the problem."

White House officials said that, at the time of this meeting, Reagan did not realize that the rule had become the key issue. He was apparently still operating on the original White House strategy, which was to tolerate some Republican opposition to the final bill but head off organized GOP efforts to block it.

Treasury Secretary James A. Baker III and White House chief of staff Donald T. Regan told the president Tuesday night that their original strategy had failed, according to White House officials. But they expressed hope that the tax bill could survive.

In working to defeat the rule, Republican deputy whip Loeffler obtained a list of more than 100 Democrats identified as uncomfortable with the Ways and Means bill. He rallied numerous corporate lobbyists and independent oilmen who flew to Washington this week to press them to vote "no," GOP officials said.

Although they denied it, the Republican leaders were widely accused by supporters of the bill of trying to kill tax reform through their procedural maneuver.

"This is nothing more than an effort to kill tax reform on the part of the Republican leadership, and some Democrats played right into it," said Nick Calio, one of the chief lobbyists for the largest business coalition supporting the bill.