Republicans preserved their 54-to-46 Senate majority Tuesday, losing two seats to the Democrats but also gaining two, including the Nevada seat that for 24 years has been held by Howard W. Cannon.

But Democrats, as their campaign committee chairman, Wendell H. Ford (Ky.), boasted yesterday, even so "came within a whisper" of snatching back control of the Senate, which they lost two years ago in the Reagan landslide.

Of the 33 races that were at stake, the Democrats won 20 to add to their 26 holdovers, and in most cases they won handily by margins of 3 to 2 and even 2 to 1.

Republicans, meanwhile, won 13 contests to add to their 41 hold- overs.

But about half the Republicans--party moderates from the East and Midwest especially -- survived by only a percentage point or two. A shift of 43,000 votes in five states -- Nevada, Rhode Island, Vermont, Missouri and Wyoming -- would have given all five seats to the Democrats.

The Democrats reelected incumbents in Florida, Maine, Maryland, Massachusetts, Michigan, Mississippi, New York, Ohio, Tennessee, Texas, West Virginia, Wisconsin, North Dakota, Arizona, Hawaii, Nebraska, Montana and Washington, and took New Jersey and New Mexico from the Republicans.

The Republicans kept control of Delaware, Indiana, Pennsylvania, Connecticut, Rhode Island, Vermont, Minnesota, Missouri, California, Utah and Wyoming, and took away from the Democrats Virginia as well as Nevada.

As of late yesterday one apparent GOP victory, by Sen. John H. Chafee over Julius C. Michaelson in Rhode Island, was still not absolutely certain because Chafee's margin was 9,000 votes and 15,000 absentee ballots were still to be counted.

Chafee, one of the moderates who barely squeaked by, had only 51 percent of the vote. Three other moderates, John C. Danforth (R-Mo.), Robert T. Stafford (R-Vt.) and Lowell P. Weicker (R-Conn.), also ended up with only 51 percent, though Weicker won more easily than that figure suggested because he had two opponents. In addition, David F. Durenberger (R) won in Minnesota with about 53 percent of the vote, while in Nevada Chic Hecht (R) beat Cannon with less than 51 percent.

"I am relieved," Sen. Bob Packwood (R-Ore.), chairman of the Senate Republican campaign committee, told reporters after reviewing these percentages yesterday.

He said that, had it not been for several "incredibly able incumbents. . . of strong personal popularity," the Senate Republicans might not have been able to overcome what, in the House and gubernatorial races, was a Democratic tide.

Packwood said his party's polls over the weekend, just before the election, "had most of our incumbents leading by 10 to 12 percent; the sudden drop to 2 to 3 percent surprised" him and other GOP figures. He said he could not explain it until more details were known about who shifted, but added, "We cannot write off the women's vote. We did badly with women and we did worse with women working" outside the home.

In the parties' swap of two seats each, Democrats lost in addition to Nevada the Virginia seat held by retiring Harry F. Byrd Jr., a conservative former Democrat who became an independent but remained a member of the Senate Democratic caucus on votes affecting Senate control.

Republicans lost the New Jersey seat held by appointed caretaker Nicholas F. Brady when Frank Lautenberg upset Rep. Millicent Fenwick (R). They also lost the New Mexico seat held by first-termer Harrison H. Schmitt, the former astronaut.

Ford and Sen. Bill Bradley (N.J.), vice chairman of the Senate Democratic campaign committee, said the election dashed Republican hopes "for a lock on the Senate," and added that Republicans "generally ran away from Reaganomics." Bradley said the GOP moderates especially "spent a great deal of time and money distancing themselves" from the president's economic program.

"It augurs well for a quite different Senate. The moderate Republicans just elected and more moderate Republicans who are up in 1984. . . will not go in lockstep" with conservative policies, Bradley contended. Ford also stressed that the National Conservative Political Action Committee had failed in most of the races where it targeted Democrats for defeat: he said eight of the nine Democratic incumberts on which NCPAC drew a bead had won.

Ford and Bradley said the scare thrown into the Republicans by the election results would probably make the Senate Republicans, in effect, demand that the administration pursue a more moderate course.

Packwood said he did not believe the Senate Republicans would simply turn left and buck the president because of the elections. But he said there obviously would have to be more compromises with the Democrats, particularly in view of their larger number of seats in the House, if the president was to get the bulk of his program through. Knowing the president's record as California governor, he said he felt Reagan would understand that "he's going to have to give" on some issues.

With Schmitt's departure the chairmanship of the Appropriations subcommittee with jurisdiction over virtually all of the labor, health and social welfare programs of the government, amounting to hundreds of billions of dollars a year, will fall open.

Next in line are Mark O. Hatfield (R-Ore.) and Weicker, followed by Ted Stevens (R-Alaska) and Mark Andrews (R-N.D.). Schmitt's defeat will also create a vacancy on the Commerce Committee.

With Cannon and Byrd departing, several choice slots will also open up on the Democratic side. Cannon is senior Democrat on the Commerce Committee; Ernest F. Hollings (D-S.C.), who is next, can have that title, which will make him chairman if the Democrats regain Senate control, or he can remain senior Democrat on the Budget Committee. If he chooses Commerce, then Lawton Chiles (D-Fla.) will become senior Democrat on Budget. If Hollings chooses Budget, Daniel K. Inouye (D-Hawaii) will move up on Commerce. Hollings said yesterday he has not decided.

Cannon and Byrd are also on the powerful Armed Services Committee, and Byrd will also leave a slot on the Finance Committee, which handles taxes, Social Security and welfare.