President Reagan, caught in what one official described as a "real tug of war" among his senior advisers, yesterday was still mulling a veto of new budget legislation that would force him to choose between a tax increase and a continued slowdown of his defense buildup.

One administration official familiar with the internal debate among the White House staff members and the president's Cabinet officers said it was "a very close call" whether Reagan will sign the legislation that strengthens the Gramm-Rudman-Hollings balanced-budget law.

White House spokesman Marlin Fitzwater said that the president, under strong pressure from Defense Secretary Caspar W. Weinberger to shield the Pentagon budget, was seriously considering a veto.

"You're talking defense and taxes," said Fitzwater. "That's pretty close to home."

Questioned about the budget bill by reporters as he left a ceremony honoring the nation's historically black colleges in the Roosevelt Room of the White House, Reagan pointed to his head, made a spinning motion with his hand and replied: "Can't you see the wheels turning? I'm still working on that."

The legislation, passed with bipartisan majorities in the House on Tuesday and the Senate on Wednesday, would require a $23 billion across-the-board cut in federal spending in the fiscal year that begins Oct. 1 if Congress and the White House cannot agree on separate legislation to reach the $144 billion deficit targeted by the bill.

The measure was supported by the Democratic leadership in Congress as a means of getting Reagan to compromise on budget issues, specifically on a tax increase that could range from $10 billion to $15 billion in fiscal 1988. If he signs the legislation, Democrats hope Reagan would back away from his pledge to veto a tax increase rather than suffer further defense cuts. If he vetoed the tax increase, the automatic spending cut mechanism would trigger reductions in defense spending in order to reach the fiscal 1988 deficit target.

According to figures provided yesterday to the Senate Budget Committee by the Congressional Budget Office, the $23 billion across-the-board spending reduction would cut defense spending authority to about $285 billion, about $6 billion below this year's level. That is about $11 billion below the figure set in the budget passed by Congress in June, which was predicated on Reagan accepting a tax increase.

Though Reagan is being urged to veto the Gramm-Rudman-Hollings repair by Weinberger and officials in the State Department, other senior advisers are pressing him to sign the measure, arguing that he will get no better deal from Congress.

Among those urging a presidential signature are White House chief of staff Howard H. Baker Jr., budget director James C. Miller III and Treasury Secretary James A. Baker III.

"The problem is Cap {Weinberger}," said one administration official who is anxious for Reagan to sign the bill.

Fitzwater said yesterday the administration's commitment to Gramm-Rudman-Hollings "remains strong," and conceded that a veto carries "some serious ramifications and that's what we are considering every way possible."

Republican leaders of the House and Senate also met with Reagan yesterday to press him to sign the legislation.

"We had our opportunity to give him our pitch," said House Minority Whip Trent Lott (R-Miss.). "He listened attentively as he always does and expressed a couple of concerns. He did not indicate what he is going to do."

Sen. Alan K. Simpson (R-Wyo.), the assistant minority leader of the Senate, said the president was assured that there will be additional chances to adhere to the administration's spending and tax policies and that the budget law revision is critical to reducing the deficit. "It's very important to get this trigger mechanism on the books to stop us before we kill again," said Simpson.

A complicating factor in the presidential decision is that the Gramm-Rudman-Hollings revival is attached to critically needed legislation raising the federal debt limit to $2.8 trillion. The existing borrowing ceiling of $2.3 trillion expired yesterday, reverting to $2.1 trillion. That leaves the government facing the prospect of a default on its maturing debt by the end of this month.

"To play around with the debt limit this way means really that you're playing with dynamite," said Treasury Secretary Baker yesterday in an interview on NBC's "Today" show. "Congress is trying to force him {Reagan} to either gut his defense budget or agree to increase taxes on the American people, so it's going to be a very difficult decision. There is a gun at his head, if you will."

Should Reagan veto the Gramm-Rudman-Hollings repair, it could trigger a debt-limit standoff with Congress with serious repercussions on financial markets.

"The markets are nervous," said Stephen E. Bell, a former Republican staff director of the Senate Budget Committee who manages the Washington office of the securities firm Salomon Brothers Inc. "The markets will go down so quick it will make your hair straight if he vetoes it."

House Ways and Means Committee Chairman Dan Rostenkowski (D-Ill.) has said he will immediately introduce a new debt ceiling bill without the budget law changes if Reagan casts a veto. However, prospects for its passage are uncertain at best.

"The real shudder is the debt limit," said Simpson. "A debt limit without a {Gramm-Rudman-Hollings} fix is almost impossible to pass in this place."

"I don't see where the votes are," agreed Lott.

A political risk in a presidential veto of the budget law is that Reagan and the Republican Party might yield the high ground on deficit reduction to the Democrats at a time when public opinion polls show that voters are beginning to view Congress as better than the president at controlling the deficit.

A veto, said one administration official, would put the GOP in a "pro-deficit position."

"If he vetoes it he would clearly be saying 'I don't really care about deficits.' It would be tragic for the nation because there would be no deficit reduction of any significance this year," said House Budget Committee Chairman William H. Gray III (D-Pa.).

Without the Gramm-Rudman-Hollings hammer, Gray predicted that Congress could come up with a spending plan that would trim the deficit by $10 billion at most.

Should Reagan choose to sign the new balanced-budget mechanism, many Democrats and some Republicans hope it will produce a round of budget talks between Congress and the White House ultimately leading to a spending and tax compromise.

"Unless we have this mechanism in place, there is no way we will have the force of coercion . . . to force that grand meeting we have all been waiting for with the leadership of these bodies and the president of the United States," said Sen. Warren B. Rudman (R-N.H.) on Wednesday.

Rudman predicted that the negotiations would be "bloody" but would ultimately yield an agreement between the two houses of Congress and the administration before the automatic spending cuts first take effect on Oct. 20.Staff writer Lou Cannon contributed to this report.