President Shehu Shagari today called his reelection to a second four-year term "a victory for all Nigerians, a victory for democracy."

Speaking at a press conference just hours after the announcement of his victory in the elections held Saturday, Shagari said: "We believe that the success of democracy in Nigeria will give a lot of encouragement to other countries in Africa."

He said Africa would remain the focus of Nigeria's foreign policy, which would continue "opposing racism, apartheid and colonialism."

The results of the election, the first run by civilians since the Army returned Nigeria to democratic rule in 1979, were announced in the early morning hours. They showed that Shagari, 58, defeated his nearest opponent, Obafemi Awolowo, 74, by more than 4 million votes, winning 47 percent of the total in the six-candidate election.

Shagari also satisfied the constitutional provision that the winner must have at least 25 percent of the vote in two-thirds of Nigeria's 19 states. He achieved that figure in 16 states--three more than needed.

Announcement of the outcome came amid acccusations by Shagari's rivals of rigging and intimidation. Two of the president's opponents took legal action in an attempt to prevent the results from being published in states where they alleged that irregularities occurred.

But election officials ignored their protests, although they ordered new elections in three towns in the eastern state of Anambra, one of the areas in dispute.

"There have been massive irregularities," Mike Ajaluchukwu, director of research and publicity for Awolowo's party, told reporters. He added, however, that the party's overriding concern was to "sustain the corporate existence of Nigeria" and he stressed that the party would use constitutional means to protest and not encourage its members to take to the streets.

There have been no reports of disturbances since the result was announced, although the delay in the counting caused some tension in Lagos. Shagari has appealed to all Nigerians to accept the verdict.

During the voting, police made 107 arrests, and correspondents noted that the late opening of some booths and missing or inaccurate registration lists impeded the vote in a number of areas.

Nigeria, black Africa's richest and most populous nation, has experienced three military coups, a civil war and 13 years of military rule since gaining independence in 1960. This election has been closely watched by African and foreign observers to see if the country's new U.S.-style constitution and its democracy would take root.

Four more elections--for governors, the Senate, House of Representatives and state assemblies--take place on successive Saturdays in the next four weeks. For now, Western diplomats agree that the relatively peaceful conduct of the presidential elections and the apparent acceptance of Shagari's victory augur well for Nigeria's democratic experiment.

After trailing Awolowo in the early counting, Shagari pulled ahead as the results from the populous, chiefly Moslem northern states began to roll in. His performance shows a marked improvement from the 1979 contest when he faced the same leading opponents, Awolowo, a veteran politician whose main support lies in the predominantly Yoruba west, and Nnamdi Azikiwe, 78, a former Nigerian president whose strength is in the largely Ibo east.

Shagari's margin increased from 700,000 in 1979 to more than 4 million this time. In 1979 he received 25 percent or more of the vote in 13 states; this time he achieved it in 16. The turnout increased from 34 percent of registered voters in 1979 to 39 percent in this election.

Much of Shagari's success, according to political analysts here, stems from his tolerant, low-key style and his ability to project himself above his party, which is far less popular than he is. Another factor, the analysts say, is his skill in appealing to Nigerians across the still high barriers of tribe, language and religion.

Shagari's new term is to be his last, and it is expected in political circles that Awolowo and Azikiwe will retire from politics, leaving the field open for a new crop of politicians.