NIGERIA IS NOW halfway through the transfer of power from a military government to civilians, one of the most difficult passages in modern politics. After long preparation, voting began in early July for state and federal legislatures, governors and finally a national president. The winner of the presidential election, Shehu Shagari, is to take office on Oct. 1. It has been an impressive performance by the generals who are voluntarily stepping down.

The last elected government of Nigeria collapsed 13 years ago in a coup generated by the regional and tribal rivalries that shortly turned into the Biafran War. When civilians last ruled in Lagos, the country's troubles were similar to those of most other newly independent countries of black Africa. The struggle toward economic development, and the crippling shortages of wealth, were much like those elsewhere. But since 1966, Nigeria has become one of the world's major oil producers and a lack of money is no longer quite the limitation that it once was. Perhaps it will also turn out that civil war has taught Nigeria, like other countries, that the art of political compromise is more valuable than it looks at first. If that is the case, it may turn out, paradoxically, that Nigeria democracy sits on firmer foundations, even after long military rule, than it did in the first years of independence.

One early test of the spirit of compromise may well be the nation's reception of the election results, as interpreted by the federal electoral commission. Precisely to avoid the kind of struggle for regional dominance that precipitated the 1966 coup, the new constitution requires the winning candidate to get 25 percent of the vote in at least two-thirds of the country's 19 states. Mr. Shagari, far ahead of any of his four opponents, got more than 25 percent in 12 states, but only 20 percent in the crucial 13th.

The four losers, happily anticipating a runoff in the electoral college, immediately began dealing and bidding in a fashion reminiscent of a deadlocked nominating convention in this country. The generals disapproved. They evidently did not wish to see power descend, by a series of scandals and private bargains, to a minority candidate. The electoral commission reconsidered, and found that Mr. Shagari's vote was more than enough. It reasoned that 25 percent in the 13th. The generals find that arithmetic and two-thirds of 25 percent in the 13th. The generals find that arithmetic logical. It suggests that Mr. Shagari will take office with the support of the military, who take pride in their constitutional preparations and wish to see them turn out successfully. That looks like another good omen for Mr. Shagari's presidency.