Former Economic Development Minister Shedu Shagari has been elected president of the new U.S.-style civilian government that will end 13 years of military rule here, according to an announcement today from the Nigerian Federal Electoral Commission.

The clear-cut Shagari victory, announced by the election commission on a broadcast by Lagos Radio, came as a surprise, since the commission had been planning a presidential runoff election until a few hours previously.

A 1977 electoral decree, designed to ensure the president would have adequate support among the country's different tribal factions requires a candidate to win a simple majority of the popular vote. However, the majority must include at least 25 percent of the votes cast in at least two-thirds of the 19 Nigerian states.

The presidential election last Saturday climaxed five weeks of voting designed to give Nigeria, black Africa's wealthiest and most powerful nation, its first civilian government since a military takeover in 1966. Gen. Yakubu Gowon, who emerged as the country's strongman after the takeover, was overthrown by other military officers in 1975.

On successive weeks since July 7, Nigerian voters have turned out to elect a 95-man Senate, a 449-member House of Representatives, 19 state governors and 1,347 members of assemblies of each of Nigeria's states.

Voter turnout to elect the president, who is slated to take office for a four-year term on Oct. 1, was about 35 percent of Nigeria's nearly 48 million registered voters, the highest level of participation in any part of the five-election series.

Besides the president and legislature, Nigeria's constitution calls for an independent judiciary. None of the country's five political parties has achieved a majority in the two-chamber Parliament.

Shangari, 54, a member of a prominent family from Nigeria's northern Moslem region, was the youngest candidate but was regarded as the most conservative of the five presidential candidates.

A former science teacher who switched to politics, Shagari held Cabinet appointments in both civilian governments and under the Gowon military administration.

Shagari was a close associate of Sir Abubakar Tafewa Balewa, Nigeria's last elected leader, who lost his life in the 1966 military coup.

Nigeria's new president withdrew from public life after the death of Tafewa, but was brought back to government by Gowon who appointed him Federal Commissioner for Economic Development.

Shagari, leader of the mainly northern-based National Party of Nigeria, led the race with more than five million votes. His closest contender was Chief Obafemi Awolowo of the Unity Party of Nigeria, with more than four million votes.

Nigeria, which exports 1.2 million barrels of oil daily to the American market, is the second-largest supplier of foreign oil to the United States, ranking after Saudi Arabia. The quality of oil produced by the West African nation, a committed member of OPEC, is particularly important to the U.S. gasoline industry.

A statement of party policy drawn up prior to the election by the victorious National Party of Nigeria indicates that the country's first postmilitary administration will maintain the basic tenets of current foreign and economic policy, while opening up to additional commercial investment.

Nigeria is likely to continue to take a strong, anti-South African line and to provide backing for black guerrilla movements in southern Africa.

Shagari is though likely to be in agreement with the decision to expropriate British Petroleum's Nigerian holdings taken last month by the present government under Lt. Gen. Olusegun Obasanjo. The measure was taken in reprisal for alleged British oil exports to South Africa.