It was the kind of political high-wire act that Washington loves but rarely sees: a brazen wave to the crowd, then a series of nerve-jangling wobbles and finally a safe landing for the star performer.

For four months, Senate Majority Leader Robert J. Dole (R-Kan.) kept the town in suspense as he tried -- often with more grit than grace -- to patch together a huge package of spending reductions that would cut deficits by half within three years without raising taxes.

The White House had tried and failed at the task; the Democrats showed no interest in trying. In his first few months as leader of Senate Republicans, Dole was still in job-training and had a mixed record, ranging from a victory on the MX missile to a rebuff from his troops on emergency farm-credit legislation.

But, from the start, the deficit-reduction effort was clearly going to be an early make-or-break test of Dole's leadership skills, made all the more dramatic by the bravado with which he launched the effort from the steps of Blair House before President Reagan finished writing his budget proposal.

It was a gamble, Dole concedes, and he was not always as certain of vindication as he appeared in public.

He knew he got off to a bad start when the Republicans promised a deficit plan by Feb. 1 and soon missed the deadline. His efforts to reach an early consensus among committee chairmen fizzled in full public view. When he then turned to the Budget Committee to draft a plan, the White House stomped all over the results. There were backroom sessions in which Republican senators were all but throwing erasers at one another.

Dole began to have at least fleeting thoughts of what it would be like to try to repair the damage from defeat.

"I could see the epitaph: 'Here lies the leader who lasted only three months,' " he said in a recent interview. He laughed but added more seriously that it would have been a "lonely six months of rebuilding" if he had failed.

However, a week ago, after a grueling trial-and-error exercise that often seemed to teeter on the brink of failure, Dole's painstaking effort paid off -- barely. Sen. Pete Wilson (R-Calif.), hospitalized for a ruptured appendix, was wheeled into the chamber, setting up a 49-to-49 tie vote that Vice President Bush broke in favor of the plan.

Shaky as it was, even Democrats credited passage as an extraordinary accomplishment, in light of the difficulties that had been surmounted, ranging from White House reluctance to tamper with Social Security or its defense buildup to the parochial concerns of Dole's troops, especially the 22 Republicans whose seats are up for election next year.

"I give him high marks . . . there's nothing quite like success," said Sen. Lawton Chiles (Fla.), ranking Democrat on the Senate Budget Committee, who had been standing by with his own plan, ready to pick up the pieces if Dole crashed.

In the process of finding a Senate consensus on spending cuts, the Dole-led Republican majority in the Senate moved further -- and more aggressively -- away from White House policies than it had done under Dole's popular but less daring predecessor as majority leader, Howard H. Baker Jr. (R-Tenn.), who has retired from the Senate.

Dole and other GOP leaders persuaded Reagan to accept not only Social Security benefit limits he had vowed never to embrace but also a major cutback in his high-priority defense buildup, concessions that rivaled any that the president made in his first term.

Dole avoided an open break with the White House largely by getting the president's lieutenants to sit down in his own office to hear about problems he faced. "We did everything we could . . . and the president knew no one up here was playing games," Dole said.

With the outcome apparently hinging on a variety of concessions, especially the defense cutback, "Dole was saying in effect, 'Mr. President, we're going to make you an offer you can't refuse,' " said Sen. Bob Packwood (R-Ore.), Dole's successor as chairman of the Senate Finance Committee.

Packwood, who is close to Dole and Baker, draws this distinction between the two: "Howard regarded himself as the president's liege. Bob regards himself as leader of Senate Republicans. And there's a big difference."

The victory, no matter how narrow, clearly enhanced Dole's clout within the Senate in a way that could help him in legislative battles ahead, according to senators of both parties.

The victory, however, was won not with the fast quips and virtuoso maneuvers that have marked Dole's public image.

Instead, it was won unglamorously, in the trenches -- in more than 100 private negotiating sessions, in parliamentary maneuvers that proved a match for Minority Leader Robert C. Byrd (D-W.Va.) and his renowned procedural skills, and with constantly shifting tactics that, in the process of skirting deadlock, wore down the opposition and created a sense of inevitability about passage.

It was also done in concert with Budget Committee Chairman Pete V. Domenici (R-N.M.), a rival for the majority leader's post who tangled over turf with Dole, then finance chairman, during previous budget battles. With Domenici's facts and figures and Dole's relentless pressure, "it was a formidable combination," said a Republican who had received the full Dole-Domenici treatment.

During the bargaining sessions, sometimes six to eight a day, often overlapping, Dole coaxed, wheedled and massaged his colleagues, individually and collectively, and cut deals in which money was restored to favored programs in exchange for votes. Sen. Edward Zorinsky (Neb.), the lone Democrat to support Dole's plan, said his vote helped produce a couple of billion dollars more for farm programs. Republicans got money for everything from Amtrak to Urban Development Action Grants; for some, Dole agreed to introduce amendments that he adamantly opposed, in hopes of winning their support in the end.

Roll was taken at the meetings, and absentees were rounded up. There were meetings for senators who refused to attend other meetings. When one senator complained that he had not been consulted, he was quickly told that he had been invited to 15 meetings and attended four. Only half facetiously, another senator said he was convinced that some of his colleagues agreed to go along with Dole simply to avoid having to attend any more meetings.

Baker, too, was a patient man with a collegial approach to leadership. But Dole, as stubborn as he is patient, appears more inclined to stick it out until he gets his way, shifting strategy as he goes but never losing sight of his goal.

"If nothing else, he's shown everyone that he can outlast them," a Democrat said. "That goes a long way around here."

Although it may bring them grief on Social Security, the plan bought Senate Republicans -- who face a tough 1988 election -- an insurance policy against economic adversity by enabling them to claim that they had voted to curb one of the major causes of high interest rates, inflation, unemployment, trade imbalances and other economic ills.

Moreover, victory was achieved without pressing the shakiest of the troops to the wall. For instance, it is thought to be no coincidence that the hair-thin margin of victory was engineered without need of a favorable vote from Sen. Paula Hawkins (R-Fla.), whose reelection is in such doubt that a vote to limit Social Security benefits as part of the package could have doomed her chances.

But it is less clear whether the victory has accomplished similar wonders for Dole as a possible contender for the 1988 Republican presidential nomination.

Hampered by an earlier reputation as a hatchetman and by a more recent image as a moderate pragmatist swimming against a tide of ideological conservatism within his party (he's been called "tax collector for the welfare state" by one of the young House conservatives), Dole has nonetheless made no secret of his presidential ambitions. And, at age 61, he may be running out of time to fulfill them.

Several political strategists, none of them serving Dole at the moment, suggested that his national reputation was helped, but not decisively, by his budget victory.

Meanwhile, Dole faces problems in the Senate, ranging from fending off further concessions in negotiating final deficit reductions with the Democratic-controlled House to keeping the Senate in GOP hands next year.

But, for the time being, he is riding high, shuttling around town to share his joy with just about anyone who will listen. As he said at a low point in the deficit struggle, "On the whole, I prefer winning."