AFTER a night and a morning of wrangling and arm-twisting, Soviet President Mikhail Gorbachev and the republican leaders standing behind him emerged triumphant.The emergency session of the Congress of People's Deputies, the country's supreme legislature, finally approved sweeping political changes. Virtually undoing the edifice erected by the Bolshevik revolution of 1917, the Congress agreed to the republican plan to convert the Soviet Union into a loose confederation, with the republics holding a veto over central policymaking. "The Congress rose to the occasion at this crucial and, without any exaggeration, historic moment," President Gorbachev said in his closing address yesterday. The Soviet leader expressed hope that the country could gain stability after the tumultuous events since the attempted putsch of Aug. 19-21. "We hope these great decisions will enable us to get out of our crisis," he said. The new Soviet leadership clearly expects that its efforts to shape a political consensus will lead rapidly to an influx of Western economic assistance. United States Secretary of State James Baker III arrives here next week on a visit in which Western aid is likely to be the primary subject on the agenda. The victory of Mr. Gorbachev, Russian President Boris Yeltsin, and the 10 other republican governments, in presenting a joint political plan at the beginning of the Congress session on Monday, was far from easy. The Congress was presented with two key documents: a resolution that described the basic principles of a transitional administration; and a bill of amendments to the Soviet Constitution reorganizing the central government in conformity with the confederate principles. On Wednesday evening, when the Congress was scheduled to conclude, Gorbachev failed to get the two-thirds majority approval needed for the constitutional changes. Gorbachev and the republican leaders worked through the night to make changes and reconvened the Congress yesterday morning to try again. Several factors blocked passage: Many conservative deputies refused to agree to a change that amounts to the dissolution of the Congress; the Russians had to appease smaller nationalities within the larger Russian Federation. When the delegates reconvened yesterday morning, Gorbachev threatened to disband the Congress if they failed to get approval. "The situation dictates that we should use more dynamic action or we may face a situation of starvation and maybe freezing during the winter," Gorbachev advisor Georgi Shaknazarov explained to the Monitor. "Unfortunately, some deputies do not want to sacrifice their ambitions and privileges." Some changes made to the documents overnight made them more palatable. The broad resolution was largely intact, but a key clause recognizing the independence of republics, opening the door to accepting Baltic independence, was amended. In order to gain independence, it added, those republics must negotiate with the Soviet Union "to solve the entire range of issues related to secession," likely to include guarantees of the rights of minorities, particularly Russians, living in those republics as well as the status of Soviet military bases. The resistance to the bill on government restructuring was focused on the effective dissolution of the Congress and the standing parliament elected from its midst, the Supreme Soviet, and their replacement with a two-chamber body including an upper Council of the Republics and a lower Council of the Union. The republican chamber was originally to be formed with 20 representatives from each republic, chosen by their legislatures. The revised version gives Russia 52 delegates, to allow for representing the "autonomous republics" within it. But each republic still has the equivalent of only one vote in the body. In the newer draft, the lower chamber was made even more subordinate to the republics with its members drawn from the existing Congress of Deputies but only in coordination with republican governments. The upper republican chamber has to approve all laws and the draft also gives republics the right to void any union law which contradicts their own legislation. With a firm-handed Gorbachev in the chair, the republican leadership moved to ram these changes through, but they ran into resistance in the vote on the new parliament. Three times the Congress fell short of the two-thirds majority needed. Gorbachev, warned the delegates: "Either we take a decision and follow the path we have agreed to or we stop here," ending the Congress. The next time, Gorbachev had his way by a safe margin. The new Supreme Soviet is to be convened by Oct. 2, giving the republican governments time to pick their representatives. Executive power in the Soviet Union, under the new law, now rests with a State Council formed by Gorbachev and the republican leaders (the post of vice president was eliminated after Vice President Gennady Yanayev joined the coup leadership). The Cabinet is replaced by an interrepublican economic committee to manage the economy. The only other all-union bodies which are explicitly retained are those dealing with defense, internal security, and foreign policy.