The Republican-controlled Senate voted 58 to 41 for production of the MX missile last night and then overwhelmingly passed a $200 billion defense authorization bill that gives President Reagan nearly all the expensive new weaponry that he wants to continue his massive military buildup.

The House passed its version of the defense authorization bill shortly before 2 a.m. today after a marathon session in which it approved a 4 percent pay raise for the military starting next January. The Senate bill calls for such a raise in April unless civilian government workers get the increase before then.

The Senate approved its bill 83 to 15. The House approved its version 305 to 114. The bills now go to conference.

The Senate's MX vote, which followed a two-week anti-MX quasi-filibuster led by presidential hopeful Sen. Gary Hart (D-Colo.), was only slightly closer than the 59-to-39 vote by which the Senate approved flight-testing for the missile last May.

Only Sen. Bob Packwood (R-Ore.), who voted for the MX in May and against it last night, switched his vote; absenteeism accounted for the rest of the difference. As before, all but a dozen Democrats voted against the MX, while all but seven Republicans voted for it. Among Washington area senators, only Sen. Paul S. Sarbanes (D-Md.) voted against the missile production money.

In a subsequent vote, the Senate rejected, 57 to 42, a proposal to knock out funds to base the MX in existing Minuteman silos and to urge development of a smaller missile that could be deployed in a mobile or deceptive manner. Sen. Lawton Chiles (D-Fla.) switched sides on that issue.

It then approved, 92 to 6, a statement urging development of a small, single-warhead missile that many MX critics see as a less threatening alternative to the 10-warhead MX. But the significance of the vote was clouded by the fact that most of the leading MX backers supported it.

The MX suffered less erosion in the Senate than it did in the Democratic-controlled House, which narrowly approved MX production funds last week. The margin of support in the House slipped from 53 to 13 between the May and July votes.

While the Senate vote to authorize $2.5 billion for the first 27 MX missiles was never in doubt, Vice President Bush made a rare appearance to preside over the chamber during the vote, apparently to underscore the administration's commitment to the controversial missile.

The Senate's vote for the defense bill, on top of the MX vote, gives Reagan a solid victory within limits that Congress approved earlier for the administration's rearmament program.

Both the Senate and House bills generally comply with earlier congressional budget decisions to restrict Reagan's military buildup for next year to 5 percent after inflation, or half what the president wanted.

But, while cutting roughly $10 billion from Reagan's request, the two bills would allow defense spending of $16 billion to $17 billion over Pentagon appropriations for this year and give Reagan most of the weaponry that he wants, including the B1 bomber and M1 tank as well as the MX intercontinental missile.

As Senate foes of the MX continued their apparently doomed fight against it, Sen. Edward M. Kennedy (D-Mass.), in an attack on Reagan's arms-control efforts, accused Reagan of a "Scarlett O'Hara performance: he will think about arms control tomorrow, while he builds MX today."

Saying that the MX vote hinges on 20 to 25 senators who oppose the missile but would vote for it to enhance U.S. leverage for an arms-control agreement with the Soviets, Kennedy charged that Reagan is using "cynical . . . tactics" in promising negotiating flexibility every time the MX looks as though it is in trouble.

"His string of vague arms-control proposals has been used primarily to lull Congress into providing sufficient votes for the MX," which would lead to a "radical and indefensible escalation of the nuclear arms race," Kennedy said.

Taking a different tack, Armed Services Chairman John G. Tower (R-Tex.) said that failure to authorize the 10-warhead missile would invite "severe and untoward consequences," including "complete Soviet intransigence" at the bargaining table.

It also could undercut British and French resolve to proceed with modernization of their nuclear forces, and persuade European allies to refuse to locate Pershing and other missiles on their soil, Tower said.

He repeated his characterization of the MX as an "indispensible" negotiating lever, and added: "The Soviets are unrivaled masters of diplomatic intransigence when they perceive that to be in their best interests."

In summing up his case against the MX, Hart said it would "bring the nation and the world to the brink of hair-trigger disaster" while giving the Soviets an "inviting target" for a knockout blow.

"They don't have to spend a dime for the $30 billion that the MX will cost," he said.

Although the bill under consideration by the Senate was $200 billion, funds for military construction and energy-related nuclear development were split off at the last, leaving a Pentagon authorization of about $186 billion, which is roughly the same as the $187 billion bill under consideration by the House.

One of the biggest differences that will have to be resolved in a House-Senate conference is a resumption of production of nerve-gas weaponry, which the House rejected and the Senate approved only narrowly, with Bush breaking a tie vote.

The House also added two conditions to its MX approval that were not approved by the Senate: one reducing the number of initially authorized missiles from 27 to 21, saving $358 million, and another linking MX production to development of a smaller, single-warhead missile called Midgetman.

In addition, the Senate approved creation of an independent office for operational testing of weapons within the Pentagon and proposed that the Pentagon establish maximum price increases for military spare parts. Last night the House also approved the independent testing office and called for a Pentagon report aimed at economies in spare-parts procurement.