Millions of Nigerians voted peacefully today in the second democratic presidential election in Africa's most populous nation since the voluntary end of military rule four years ago.

Despite widespread administrative foul-ups, few incidents were reported in the six-candidate election in this country that has experienced political turmoil and has yet to erase fully the memory of the 1967-70 civil war, in which about 1 million Nigerians died. The election was seen as an important test of stability on a continent where pluralistic democracy is rare and election-day violence common.

The balloting ended a lively campaign in which the personalities of the three leading contenders were seen as more important than the issues. The top contenders are the incumbent, Shehu Shagari, 58, and the two elder statesmen of Nigerian politics, Obafemi Awolowo, 74, and the nation's first president, Nnamdi Azikiwe, 78.

Results are not expected before Monday. The election is the first of five that will be held on successive weeks. Subsequent elections will elect 19 state governors, senators, representatives and state legislators, but today's election was seen by western observers and voters standing in line as the most crucial one.

With a population estimated to be as high as 100 million--one-fourth of the continent's inhabitants--Nigeria is the world's fourth-largest multiparty democracy, behind India, the United States and Japan. It is also a leading oil producer and still the second-leading exporter of petroleum to the United States, although oil revenues have declined because of a worldwide glut in oil supplies.

Today's election was the second of its kind in black Africa this year. Senegal held a peaceful presidential election in February to choose a successor to its longtime leader, Leopold Senghor.

Nigerian Transportation Minister Umaru Dikko acknowledged that there were numerous hitches in today's election, but he predicted that the turnout would be much larger than the 18 million who voted in the 1979 election.

Voting started late in many places because of missing voter registration lists. In addition, the names of registered voters had been dropped in many places, and ballot boxes were not delivered until midday at other of Nigeria's 156,000 polling booths.

Prior to today's election, there had been widespread reports of political operatives buying valid voter registration cards for $75 and and padding the voter rolls with fictitious names.

One foreign source here, who insisted on remaining unidentified, predicted that there would be more "problems with maladministration of the election than fraud or vote rigging."

Voters stood in the rain for hours outside plywood and corrugated metal booths in the interior city of Kaduna, 525 miles north of Lagos, the capital. In the eastern city of Enugu, 356 miles away and the former capital of the Ibo secessionist state of Biafra, voters stood for hours in a hot tropical sun before some polling stations opened at noon, five hours late. Foreign reporters visited Kaduna and Enugu in a small jet provided by the Transportation Ministry.

Nigeria, which was granted independence from Britain in 1960, had a Westminster-style parliamentary system of civilian government until that collapsed into anarchy. The nation experienced several bloody coups and the civil war before creating a presidential system modeled loosely on that of the United States. Shagari came to power in 1979, after the Army voluntarily handed over power.

Because of past experiences with violence on election days, a regular feature of Nigeria's first civilian government in the 1960s, security measures today were tight--as when the Army supervised the 1979 elections at the return to civilian government. In Enugu, uniformed Air Force personnel, Army troops and steel-helmeted policemen carrying automatic rifles jointly manned roadblocks and checked the trunks and glove compartments of all cars for weapons. The police alone, however, watched the polling stations.

But there were no significant reports of violence in what was predicted to be the most tense of the five elections.

Of the three main contenders, President Shagari, who won by a relatively small margin in 1979, is considered by many political observers here to be the leading candidate. Shagari, who heads the National Party of Nigeria, is a member of the largest of the country's three major ethnic groups, the mainly Moslem Hausa-Fulani who dominate the country's northern region. Observers feel he has the widest support across tribal lines, having made inroads into the other two candidates' ethnic strongholds.

Awolowo, who is expected to received the second-largest plurality, has the strong tribal allegiance of his Yoruba people in Nigeria's densely populated southwest area. His Unity Party of Nigeria also has made progress in non-Yoruba areas in the past four years.

In the campaigning, Azikiwe faced a strong challenge to his leadership of Nigeria's third-largest group, the Ibos, from Emeka Ojukwu, the former Biafran civil war military leader who returned from exile a year ago after receiving a presidential pardon from Shagari. Ojukwu has advocated that the Ibos break away from Azikiwe's Nigerian People's Party and join with him in Shagari's National Party. If the charismatic Ojukwu, 49, is successful in his drive, analysts say, it could have a significant impact toward reducing ethnic divisions in Nigeria for years to come.

Ojukwu is running for the Senate on Aug. 20 in one of the more pivotal electoral battles shaping up in the coming weeks.

The presidential election results are scheduled to be released by the Federal Election Commission Monday, but they may be delayed because of the late starts today and the challenges of people who were turned away from the polls because they did not show up on registration lists.

Minister Dikko indicated that the polls would stay open past the 6 p.m. closing time if there were still lines of voters. "If we don't keep them open, there'll be a revolt," he said.

Electoral commissioner Nashabaru Gumel said in Kaduna today that the commission's foul-ups were a result of the massiveness of the vote and the newness of the process. "We're learning through our mistakes, and we hope to do better in 1987," he said.

Concerning angry voters who spent hours in line even before the polls opened, Gumel added that "this is natural. You must be frustrated at times when things don't go smoothly."

The election commission claimed to have registered 65 million voters, but many western observers and informed Nigerians said the number appears to be greatly inflated by padding and errors in counting. There were 48 million registered voters in 1979, and even that figure was considered high.

One angry voter, 26-year-old Musa Audu, said in Enugu that he was going to stay at the Abakalaki Road primary school polling station until he was allowed to cast his ballot. Audu, a tailor, had been turned away shortly after the voting began late at 11 a.m. because his name was not on the voters' list, although he held his voter registration card in his hand.

"It is not right that they should not let me vote," said Audu. "It is not my fault my name is not on the list, and I have been here since 6 a.m."

At noon, members of the crowd of about 700 began to shout at the polling official that they were moving too slow and that the sun was hot, but none moved from their places in the six long lines waiting to enter the polling booths.