Ronald Reagan has the pieces in place and the machinery to deliver a Republican presidential victory on Tuesday.

About all that can save Jimmy Carter's job is the return of the hostages from Iran or some other event that persuades large majorities of the undecided and John B. Anderson voters in about a dozen key states that they want to see Carter -- not Reagan -- in the White House.

That is the message of a final pre-election, state-by-state wrapup by The Washington Post. The report is based on the judgments of professional politicians in both parties, the reports of correspondents in all 50 states, and a variety of private and public polls.

Although Carter has a narrow lead in some recent national polls, including one by The Washington Post, it appears that Reagan could lose the popular vote and still win an electoral vote victory, or he could win both.

The Post wrapup, detailed on pages C4 and C5, shows the former California governor ahead this weekend in 22 states with 207 electoral votes -- just 63 short of the 270 needed for victory. President Carter went into the final 48 hours leading in 15 states and the District of Columbia, with 163 electoral votes.

Thirteen states with 168 electoral votes were rated too close to call. To salvage the election that Reagan clearly would have won if the voting had taken place in the past 48 hours, Carter needs to win two-thirds of the electoral votes in the tossup category. As a practical matter, that probably means he must win three of the four big Great Lake states that have 99 of those votes.

The final frantic campaigning will focus on Pennsylvania, Ohio, Michigan and Illinois, but the latest available indicators from private and public polls are that it is Reagan -- not Carter -- who can claim whatever tiny edge there is in these tossup states and probably has the momentum in his direction in all of them but Pennsylvania.

State soundings confirm that Reagan gained a fairly consistent 5-point lift from his showing in last Tuesday night's televised debate with Carter. But that "ride" predictably had lost its force by Friday and overnight surveys in a few key states showed the race stabilizing.

The fact that Carter failed in the debate either to paint Reagan as a dangerous personality to occupy the Oval Office or to shift the issue from economics to foreign policy is one reason that attention increasingly has shifted to the possible hostage release as the issue that could salvage the election in the final 48 hours.

The president has experience with such turnabouts. In 1976, his Republican opponent, Gerlad R. Ford, came out of the final debate and put on a blitz that moved him ahead in the Sunday morning opinion polls. But then the voters took another look and decided to go back to the Democratic nominee.

But 1980 is not 1976. From the day he was nominated, Reagan has had a bigger margin in the Electoral College base than he has enjoyed in the national opinion polls.

Because the race appears to be stabilizing, there may be an opportunity for Carter to improve his position in the last 48 hours -- if he can find a message to sway the voters.

On his last frantic forays, the president -- who plainly knows from his own advisers what fierce odds he faces -- is wrapping himself in the mantle of the Democratic Party and, at the same time, suggesting that he has learned from experience and will be a better president in the next four years.

But Carter's version of the Richard Nixon "four more years" refrain is being thrown back at him in spades by Reagan, who is asking his audiences if they want "four more years of inflation, high interest rates and unemployment." t

The Post roundup indicated that Reagan has largely held his Western base intact. Carter could swing Oregon and Washington from the GOP column -- he will be in both states Monday -- but California, the big prize, looks out of reach.

At this point, both Texas and Florida are leaning to Reagan. Carter has only an outside chance of repeating his 1976 win in Florida, and keeping Texas will require the greatest mobilization of black and Chicano votes in history, because the Republicans there are organized as never before to deny Carter the prize he won last time.

Anchored by the Western and Great Plains base, Texas and Florida, Reagan need only annex such 1976 Ford states as Indiana, Iowa, New Hampshire, New Jersey and Virginia to run his total past the 200 mark.

In trying to block Reagan from gaining those last 70 votes for victory, Carter faces two serious problems -- leakage of support in his Southern base and the inability of the old liberal-labor coalition to mobilize as overwhelmingly for him as it has done for Democrats in the past.

Carter managed a near-sweep in the South last time by holding the black vote and winning a larger minority of the whites than any Democrat since Lyndon B. Johnson. The blacks are still with him but Reagan has cut heavily into his conservative white support.

During the last few weeks, the terrain of the southern battlefield has shifted against Carter. What were originally viewed as battleground states -- Florida and Texas -- have slipped to Reagan, and now Carter is fighting to preserve states like Louisiana and Mississippi from the western invader, and even diverting previous time to the defense of such 1976 strongholds as Tennessee and South Carolina.

Reagan, by contrast, has been able to run a more targeted campaign in the Great Lakes battlegrounds these last days, while Carter has scrambled to cover more bases. Reagan spent all of yesterday and today in Michigan and Ohio, while Carter sprinted through five states seeking help.

In those industrial states where Reagan is seeking to lock up his victory, Carter has few of the resources other Democrats could rely on. Most of organized labor is working hard for him, but the problems in steel and coal and the flabbiness of their unions' political muscle shows. There is a cost for Carter in the feuds and scandals that have rocked the old machines in such cities as Chicago and Philadelphia, and even from the population shifts that have shrunk their political power relative to their more Republican suburbs.

All these are long-term trends whose consequences fall on this particular president. But his shaky relations with the liberal-labor coalition at the heart of the historic Democratic Party are of his own making -- and they weigh against the success of his closing drive.

Nowhere is this more evident than in the polls released this weekend by newspapers in New York and Massachusetts showing Carter has but a shaky hold on the electoral votes of those two states -- where the Reagan campaign decided weeks ago that the climate was too liberal for him to have much of a chance.

A Boston Globe poll today showed Carter only 4 points ahead in Massachusetts and a Newsday-Gannett News Service poll in New York found him with a statistically insignificant 2-point bulge. Obviously, an election in which the Democrat is fighting desperately in the final days for New York and Massachusetts would be a Republican landslide nationally.

Carter's situation is not that desolate, but these polls suggest how hard it will be to mobilize the machinery of labor and the liberally oriented Democratic organization for a president who has never really bridged his cultural and political differences with these groups. It is doubly difficult because of the economic setbacks many bluecollar Democrats have suffered in the last four years.

The polls also show the seriousness of the problem that Anderson's independent candidacy represents to Carter. By offering a haven for those reluctant to choose between Carter and Reagan, Anderson is shrinking Carter's margins in the Northeast, jeopardizing his chances in such states as Connecticut and New Jersey and -- on the other coast -- creating a roadblock for Carter in Oregon and Washington.

But the Anderson vote cuts both ways. It is one of the reasons Reagan has had a hard time locking up Illinois -- though today's final Chicago Sun-Times poll has him finally nosing in front. And it is bleeding him in such northern New England states as Maine and Vermont to the point that they are possible Carter pickups.

The Post roundup has some slightly optimistic implications for Carter partisans. It clearly indicates that the election on Tuesday is not locked up for Reagan, no matter how good his odds if the voting had been held in the "halo" of his performance in the debate.

The numbers show that, contrary to the claims of some Reagan strategists, Carter does not have to sweep the Great Lakes states plus California in order to win. He could lose California, Texas, Florida and New Jersey and still have a reasonable crack at victory if he could keep Reagan from winning more than one state in the band from New York to Illinois and Wisconsin.

But the odds are still against Carter, as a comparison of his current situation with the 1976 results shows. The Post roundup indicates that Carter has a reasonable chance at winning seven states with 77 electoral votes that went to Ford last time: Maine, Vermont, Connecticut, Michigan, Illinois, Oregon and Washington.

Reagan, however, has equally good or better opportunities in nine states with 138 votes that Carter carried in 1976: Texas, Florida, Louisiana, Mississippi, Missouri, Wisconsin, Ohio, Pennsylvania and Delaware.

Since Carter had only 27 surplus electoral votes in his 1976 bag, the risks to him in this situation are evident.

Equally evident are the possible benefits to the GOP if the Reagan boom that was rolling from Wednesday through Friday should extend to Election Day.

The reports to The Post indicated brightening Republican prospects in Tuesday's Senate races. There are 10 states where Republicans have a good to excellent chance to take over Democratic seats and only three where they risk losses. Nine is the magic number for the GOP to gain a majority and while the odds are against all of those races falling into line, a strong Reagan showing could help deliver most of them.

Of the four most heavily targeted Senate liberals, late polls indicate Frank Church of Idaho is running ahead, Birch Bayh of Indiana and John C. Culver of Iowa are about even and George S. McGovern of South Dakota is still trailing. But all four contests are very close.

The other endangered incumbents include Sens. Warren G. Magnuson of Washington, Gary Hart of Colorado and John Durkin of New Hampshire. The Republicans also have a crack at electing their conservative candidates in three open seats in Florida, Alabama and Alaska where the Democratic incumbents were defeated in primaries.

By contrast, the only solid Democratic chances for gaining seats lie in New York, Pennsylvania and Oklahoma, where Republican incumbents either lost primaries or retired. The number of women senators could triple if GOP candidates Paula Hawkins and Mary Estill Buchanan score in Florida and Colorado. Hawkins is favored and Buchanan is an even-money bet.

The makeup of the House is less likely to be altered dramatically, but some big-name Democrats may not be back. With about 80 of the 435 districts boasting serious contests, a "normal swing" might produce a GOP net gain of 15 to 25 seats, with the probability it would be in the lower end of the range.

But, as a GOP strategist remarked on Friday, "We have enough races that have fallen into place that a 2 or 3 point lift from the top of the ticket could really change our numbers."

House Majority Whip John Brademas of Indiana may be the most vulnerable of the Democratic big-shots. But Public Works and Transportation chairman Harold T. (Bizz) Johnson of California, economic and energy policy powerhouses James C. Corman of California, Thomas L. (Lud) Ashley of Ohio and Bob Eckhardt of Texas are all hard-pressed.

Three of the six congressmen implicated in the Abscam investigation are favored in their reelection bids: Reps. John M. Murphy of New York, Frank Thompson of New Jersey and Raymond F. Lederer of Pennsylvania. But South Carolina's John Jenrette and Pennsylvania's Michael (Ozzie) Myers are underdogs and the only Republican, Rep. Richard Kelly of Florida, has already lost his primary.

There are only 13 governors' races on the ballot and most of them seem certain to see no change in party control. Republicans have a chance to take over in Missouri, North Dakota and Washington. But the governors with the most familiar names -- John D. (Jay) Rockefeller IV (D) of West Virginia and Pierre S. (Pete) DuPont (R) of Delaware -- will be back.