The Senate yesterday failed--by a scant five votes--to override a presidential veto of a bill that would have allowed President Reagan to allocate oil supplies and set prices in an emergency.

The 58-to-36 vote handed the White House a major victory on what some on both sides considered a minor issue.

"It's not the kind of issue that should have provoked that kind of political confrontation," said Sen. James A. McClure (R-Idaho), the bill's chief sponsor. McClure said that intensive White House lobbying had turned around the vote in the Senate, which had approved the measure twice before by large margins.

Before the measure died yesterday, however, it set off a lobbying battle that pitted Senate Republicans against House Republicans and oil industry lobbyist against oil industry lobbyist.

Besides offering the spectacle of populists and some oil company presidents on the same side of the issue, it also posed a problem for rural conservative Republicans, who found themselves forced to choose between farm groups and their president.

Reagan has said all along that he didn't want the authority that the bill would have provided.

It would have allowed the president, if he declared that an oil supply crisis existed, to invoke powers to route supplies to where they were needed most and to set price controls. It would require that a standby plan be drafted and kept on the shelf.

Many of the arguments yesterday, in fact, focused on how little the bill would have done.

"It's very limited, very temporary authority limited solely to the discretion of the present occupant of the White House," said McClure.

McClure was echoed by Sen. J. Bennett Johnston (D-La.), who added, "If you can't trust Ronald Reagan not to overuse these powers, who can you trust?"

The bill's opponents argued that it violated the White House commitment to the free market, that the administration has adequate powers to deal with a crisis and that it would re-create the chaos that they said characterized the Emergency Petroleum Allocation Act, which expired Sept. 30, 1981.

The bill was also opposed by a handful of senators who said it did not do enough.

"That bill would have sent the wrong signal to consumers at the wrong time," said Sen. Charles H. Percy (R-Ill.). "It would have created the dangerous illusion of energy security."

McClure reminded those opponents that other measures had been defeated and said that an aide to Reagan had conceded that if the White House would accept any bill it would have been McClure's.

Some of the major oil companies, including Mobil, had supported the bill before it was vetoed. Mobil had written the president urging him to sign the bill.

Congressional sources said yesterday that some oil companies that supported the bill had been silent since the veto, and McClure said he thought that the silence might have cost him some votes.

He noted that the two Texas senators had voted to sustain the veto and said that they originally had voted in favor of the bill.

Three Democrats--Lloyd Bentsen of Texas, David L. Boren of Oklahoma, and Bill Bradley of New Jersey--voted to sustain the veto.

McClure said he had been uncertain of the outcome when he came to the Senate floor yesterday. House supporters of the bill were busy laying plans for the vote in that chamber, clearly expecting an override.

"I knew the White House was working very hard to turn the votes around," said McClure. "I knew it would be very close."

White House communications director David Gergen said last night that Reagan phoned 10 Republican senators yesterday and talked six of them into changing their positions and voting for him. Vice President Bush also worked the telephones, Gergen said.

"We had assumed it was a lost cause in the Senate . . . it was a stunning surprise . . ., Gergen said.

A major message from the White House to Republican senators during the lobbying was "don't tread on me," McClure said.

"I would have thought that if people were concerned about presidential intransigence, they would have wanted to fire a shot across the bow," he said. "But maybe too many of them were worried about their aim--that they might have hit."