he ruling National Party won a narrow victory yesterday in its first electoral test against the far-right Conservative Party, formed five months ago by a breakaway group opposed to the government's plans to relax South Africa's strict segregationist system.

Political analysts saw the result as indicating that the white Afrikaners who dominate the political system oppose the reforms much more strongly than was realized. The analysts suggested that the government might backtrack to try to consolidate its support.

The by-election was in Germiston district, near Johannesburg, to fill a vacancy in the Transvaal provincial council. It was not the best area for the Conservative Party to have its first test. Opinion surveys have indicated that its main strength is in outlying rural areas, while Germiston district is in the industrial heartland of Witwatersrand.

The National Party candidate won 3,867 votes, compared with 3,559 for the Conservatives and 1,638 for the Herstigte Nasionale Party, an even more extreme right-wing group. Together, the two rightist parties won 1,330 more votes than the ruling party's candidate.

It is not only on the right that the National Party is in trouble. In a simultaneous by-election for a municipal seat in the capital of Pretoria yesterday, a taxpayers' federation backed by the National Party kept its seat but lost a significant number of votes to both the Progressive Federal Party on the left and the Herstigte Nasionale Party on the right.

The National Party's split was triggered when Prime Minister Pieter W. Botha last March proposed power sharing with the Colored (mixed-race) and Asian minorities. His plans excluded the majority blacks, who are expected to exercise self-rule in "tribal homelands."