Warned by his top economic advisers that the shaky financial markets desperately need reassurance, President Reagan last night gritted his teeth and swallowed much of his evident distaste for considering higher taxes in a deficit-cutting deal with the Democratic-controlled Congress.

Reagan went into the news conference after an extraordinary preparation by a handful of senior officials, including Treasury Secretary James A. Baker III, White House chief of staff Howard H. Baker Jr. and Federal Reserve Board Chairman Alan Greenspan. In the last two days, sources said, they drilled into Reagan in private meetings the need to appear willing to accept tax increases he has long opposed to calm the markets.

"You can tell he really doesn't like the music, but he knows he has to dance," House Budget Committee Chairman William H. Gray III (D-Pa.) said after watching the president deflect a dozen questions aimed at evoking his old antitax position.

Key Republican legislators also said they believed the president's stance opened the way for serious negotiations on a budget package and predicted that the toughest barrier may be Democratic reluctance to sign off on real domestic spending cuts.

The general tone of Reagan's first Washington news conference in seven months -- focused largely on economic concerns triggered by the past week's stock market "meltdown" -- was welcomed by Democratic presidential hopefuls and by administration officials.

"He kept all the options open. He stuck to what we wanted him to say," said one senior administration official. Another called the news conference a "mixed bag" of Reagan's plan to signal his openness to compromise, clashing at times with his past instinct to bash the Democrats in Congress.

Rep. Richard A. Gephardt (D-Mo.), one of the aspirants for the 1988 nomination, said, "There is no substitute for a president who sits down with Congress and negotiates a bipartisan solution to the nation's economic problems, and I applaud President Reagan for agreeing to do it."

Sen. Paul Simon (D-Ill.), former Arizona governor Bruce Babbitt (D) and Massachusetts Gov. Michael S. Dukakis (D) -- other Democratic hopefuls -- also urged congressional Democrats to meet Reagan halfway.

Reagan appeared calm and self-assured at most points in the nationally broadcast news conference, and clearly wanted to convey a sense of confidence to badly shaken viewers in this country and in financial markets around the world.

Talking both of the stunning drop in stock prices and the escalating military exchanges in the Persian Gulf, Reagan said, "There's nothing to panic about."

But if there was an undercurrent of tension in the East Room, it came from the evident ambiguity of Reagan's feelings about being cornered by circumstances into direct negotiations with the congressional Democrats under terms which forbid him flatly to rule out any tax hikes. Reagan seemed to be sending two messages. He wanted to signal Wall Street that he will compromise with Congress, but he wanted to tell the public he still believes Congress is at fault for the deficit.

Time and again, reporters almost taunted him by recalling his past statements that taxes would rise "over my dead body," or the forecast by his 1984 rival Walter F. Mondale that Reagan would be forced to the position in which he now finds himself.

Time and again, Reagan looked as though he wanted to throw the challenge back in the questioners' faces -- but apparently recalled that he must not appear too dogmatic.

"He was holding his tongue," said a White House official. "He knew everyone was going to taunt him -- we expected that."

At several points, Reagan appeared to wander from the opening statement that he is putting "everything" on the table, including taxes. "I'm going to tell you I have not changed my opinion about ever accepting a tax that will have a deleterious impact on the economy," he said. "And most tax increases do."

Reagan also let loose with many of his longtime charges that the record deficits of his term are the fault of Congress. "The president of the United States cannot spend a nickel," he said. "I think that I was perfectly justified in saying that a president is not responsible for this." Reagan did not mention his successful effort to reshape spending priorities and cut taxes in his first term.

Prior to the stock market crisis, Reagan was loath to accept any tax increase. He had personally forbade chief of staff Baker from even discussing it with Congress, a message reinforced recently by Treasury Secretary Baker. But after the Wall Street crash, both Bakers, joined by the persuasive presence of Greenspan, pushed Reagan hard at least to negotiate on taxes.

Greenspan met with the Treasury secretary over breakfast yesterday. The two Bakers, joined by deputy chief of staff Kenneth M. Duberstein, then met with Reagan in the Oval Office.

They decided to release a statement expressing a willingness to negotiate with Congress while the stock markets were still open and to repeat the message again last night, officials said. Greenspan was also invited to the White House later in the day, officials said.

Key members of Congress heard both the ideological and the pragmatic sides of Reagan's message -- and decided to latch on to the practical side as most hopeful.

Gray, the House Budget Committee chairman, said it was "absolutely not true," as Reagan maintained, that Congress had ignored his budgets and exceeded his spending requests. "I brought his budget to the House floor this year," Gray said, "and only 27 folks voted for it."

But Gray said, "I'm optimistic" about prospects for a deficit agreement, "because I think people have been telling the president this is no longer a matter of ideology, it's a matter of real money."

Sen. Pete V. Domenici (R-N.M.), the ranking minority member of the Senate Budget Committee, said, "I get a clear signal that if members of Congress on both sides of the aisle don't want to polarize the issue around taxes, but want a real balance with domestic and defense cuts, the president is saying we can have a deal. But there has to be parity."

And Rep. Bill Gradison (R-Ohio), a key member of the Budget and Ways and Means Committees, also predicted that it would be "easier to reach agreement on the revenue side now than on the spending cuts."

All three of these legislators noted that Reagan's objections to "tax increases that would hurt the economy" might well be avoided by leaving intact the rate cuts provided in the 1986 tax reform bill and finding revenues from other sources, as the bills already reported by the Ways and Means and Senate Finance Committees do.

Vice President Bush, who said in his official announcement speech last week that he would not raise taxes, reiterated that position yesterday despite Reagan's new conciliation. The deficit solution "is not to raise taxes; it is to restrain the growth of federal spending," he said.

Rep. Jack Kemp (R-N.Y.), a GOP presidential contender, said Reagan "should pledge to veto any tax increase," something the president declined to do last night.

Staff researchers Michelle Hall and Colette T. Rhoney contributed to this report.