In an important state election that nearly ended in a dead heat tonight, West Germany's Christian Democratic Union managed to retain control of the parliament in the state of Schleswig-Holstein.

The Social Democratic Party, which rules West Germany in a coalition government but is out of power in several states, fell only one-tenth of a percent short of gaining a tie in the election. That would have created a situation fraught with confusing possibilities for the federal parliament as well as the state government.

The conservative Christian Democrats won 48.3 percent of the vote, a drop of 2.1 percentage points from their total four years ago, but managed to capture the same number of seats, 32, in the 73-member legislature. The Social Democrats got 41.7 percent of the vote, up 1.6 percentage points over 1975. They captured 31 seats, an increase of one, but one short of what they needed to offset the loss of a one of the five seats, held by their coalition partners, the smaller Free Democratic Party.

The results appear to reflect growing strength of the Social Democrats of Chancellor Helmut Schmidt. Moreover, the outcome may be pleasing privately to the federal government for other reasons.

For example, the influential Frank furter Allgemeine newspaper asked editorially this week whether a victory would have helped Schmidt. He is viewed as more conservative than much of his party. The Schleswig-Holstein outcome maintains the conservative majority in the upper house of the federal parliament. Thus, Schmidt gets help in keeping the left wing of its party in line since the conservatives can veto some legislation.

A tie also would have affected Bonn's policy toward nuclear energy. While the federal government endorses a cautious policy of continued nuclear power development, the party's candidate in the state campaigned against nuclear power.