Sweden's nonsocialist parties hung onto power by a thread today in an extremely close national election that will not be decided until about 40,000 absentee ballots are counted later this week.

When the rest of the more than 5.2 million votes cast yesterday were tabulated early this morning, the nonsocialist parties had won 2,060 votes more than Olof Palme's Social Democrats and their silent partner in parliament, the Communists.

But under Sweden's complicated system of proportional representation, the Social Democrats and Communists stood to gain control of parliament by a single seat. This would change, however, if the nonsocialist parties win enough of the absentee votes to swing that one seat back to them, as election analysts here believe it will.

That would retain control of parliament for the nonsocialists, who ended 44 years of Social Democratic rule by winning the last election in 1976. But it would leave open the question of whether the three frequently quarrelsome nonsocialist parties could successfully agree on a new coalition government and select one of their leaders to become prime minister.

The big winners among the nonsocialist parties were the Conservatives, whose campaign for income-tax cuts increased their strength from 15.6 percent of the vote and 55 seats in parliament in 1976 to more than 20 percent of the vote and at least 72 seats in yesterday's balloting.

But it is still considered politically impossible in Sweden for the leader of such a right-wing party to become even a coalition prime minister. That would leave the other two nonsocialist party leaders, Thorbjorn Falldin of the Center Party and the present prime minister, Ola Ullsten of the Liberal Party.

Neither of these parties performed as well yesterday as expected, however. The ecology-minded Center Party fell from 24 percent of the vote and 86 seats in parliament in 1976 to 18 percent and 64 seats -- their poorest showing in many years. The Liberals failed to capitalize on the personal popularity of the wry, youthful Ullsten, and lost one seat in parliament and a little of the 11 percent of the vote they won in 1976.

The Social Democrats once again won more of the vote than any other single party -- nearly 44 percent -- and 155 seats in parliament, subject to the count of the absentee ballots.The Communists increased their vote to 5.6 percent and their seats in parliament to 20 from 17 in 1976.

This election was considered crucial for Palme and the Social Democrats, who created and expanded Sweden's cradle-to-grave welfare state. The party has split internally over just how far down the road to socialism it should go. Palme's sometimes arrogant manner and apparent preoccupation with world rather than Swedish issues also were blamed by some critics for the party's problems.

Fighting for his political life, Palme worked hard to dispel that image during the campaign, moderating his sharp debating style, traveling the country and appearing to humble himself. His nonsocialist opponents, meanwhile, bickered over some issues and appeared to criticize each other as much as Palme, leaving voters confused about just what the alternative to Palme was.

The flamboyant, intellectual Palme became a prominent international figure while he was Swedish prime minister from 1969 until 1976, criticizing U.S. conduct of the war in Vietnam, and offering moral and monetary support to Third World revolutionary movements.

But his Social Democratic Party steadily lost support inside Sweden as the country reached the outer limits of the welfare-state frontier. Increasing numbers of voters grew restless about taxes -- the highest in Europe -- and the size and sometimes arbitrary power of the welfare state bureaucracy. The Social Democrats' share of the vote fell steadily until it totaled 43 percent in the 1973 and 1976 elections.

Palme remained prime minister in 1973 when the Social Democrats and Communists barely managed to win 175 of the 349 seats in parliament. But he and the Social Democrats were ousted in 1976, when the three-party, nonsocialist coalition won 51 percent of the vote and 180 seats with a single campaign slogan: "It's time for a change."

The nonsocialist coalition was helped in 1976 by two emotional issues that domincated the last weeks of the campaign: nuclear safety and a plan favored by the Social Democrats to help capital funds controlled by labor unions take over ownership of Swedish businesses.

Center Party leader Thorbjorn Falldin, a sheep farmer who became an ecological crusader in politics, benefited from his campaign promise to cut back Sweden's nuclear energy program, proportionately the largest in Europe, because of questions about reactor safety and the disposal of nuclear waste.

Falldin became the first nonsocialist Swedish prime minister in 44 years. But he resigned last year after a government commission -- and his coalition partners -- decided that the nuclear power program should go ahead with additional reactors and with a controversial plan to store nuclear waste in granite caves 1,500 feet below ground.

Liberal Party leader Ola Ullsten took over as prime minister and supervised completion of the nonsocialist government's rescue of the Swedish economy from its worst recession in decades. Ironically, it was accomplished in part with more government involvement in the ailing shipbuilding, steel and wood-pulp industries and in a job-subsidy program than the Social Democrats would have dared try. Despite Sweden's extensive and expensive welfare state, more than 90 percent of the industry is privately owned, and opinion polls show that Swedes want it to stay that way.

The Three Mile Island reactor accident in Harrisburg, Pa., more important politically here than in the United States, threatened to turn today's election into a nuclear referendum that probably would have benefited Falldin's Center Party most. But the other parties decided instead to hold a national referendum next March on how many more nuclear reactors should be built here.

Without that issue, the Center Party plummeted in pre-election public opinion polls while the right-wing Conservatives gained steadily to become the most popular nonsocialist party.