Tens of thousands of Portuguese lined the pavements and plazas of Lisbon for more than five hours today to catch a glimpse of Premier Francisco Sa Carneiro's funeral cortege. As the procession wound its way through 12 miles of city streets, it brought national emotions to an unpredecented pitch on the eve of crucial presidential elections.

On what was technically a prepoll "day of reflection" when campaigning is forbidden by law, Sa Carneiro's mourners turned the spectacular funeral into a last attempt to oust their lost leader's main political opponent -- President Antonio Ramalho Eanes, who is seeking reelection Sunday to a second, four-year term with the official backing of the socialist and communist opposition.

The wave of emotion that has swept Portugal since Sa Carneiro was killed in an airplane crash Thursday could tip the 7 million eligible voters against Eanes, who had been the clear front-runner in the campaign. The prime minister, who came to power in January, was the architect of the ruling center-right coalition, the Democratic Alliance, which brought the right back to power for the first time since the 1974 revolution.

Heading the funeral cortege was the incumbent president's main election rival -- a tough anticommunist fellow general, Antonio Soares Carneiro, who was handpicked by Sa Carneiro (no relation) to represent the alliance.

A grim Eanes had to endure jeers and catcalls as he arrived for the funeral service at the 16th century Los Jeronimos Monastery, which was also attended by the prime ministers of Belgium, France and Spain, among other political leaders. Eanes then retired to his presidential palace while Soares Carneiro joined the funeral cortege.

The slow procession to the cemetery rapidly became a vast and noisy political demonstration. The coincidental similarity in the surnames of the dead premier and his presidential protege allowed the crowds to alternately shout "Sa Carneiro, Soares Carneiro."

The state television monopoly, which gave full, live coverage of the funeral service and the ensuing cortege through Lisbon, appeared to break the strict ban on propoll politics with shots of the crowd giving the Churchillian victory salute that the late prime minister employed.

Throughout the presidential campaign the polls put Eanes comfortably ahead of Soares Carneiro by as much as 20 percent. Although a poor, almost diffident campaigner, Eanes was better than his rival. Soares Carneiro was a political unknown until Sa Carneiro and the alliance leadership chose to pit him against the incubent president.

Although he is backed by the Socialists and Communists, Eanes, 45, favors Portugal's continued membership in NATO, entry into the European Community and broad centrist politics. Soares Carneiro's campaign, master-minded by the late prime minister, branded Eanes as a communist front man and called on the voters to choose between the stability assured by the Democratic Alliance candidate or the chaos that would follow the reelection of the left's representative.

To drive the point home, Sa Carneiro threatened during the presidential campaign to resign if Eanes were returned to office.

The left, and in particular the Communist Party, have branded Soares Carneiro, 52, a right-wing extremist and have alleged he was guilty of atrocities when he served in Angola, as part of the colonial administration when Portugal still ruled the African country. oEanes' campaign has presented the president as the defender of a political consensus that is deemed essential for Portugal's fragile and often faltering democracy.

Eanes and Soares Carneiro will take the lion's share of the vote, but a 51 percent share is needed to win the first round and avoid a runoff scheduled for Dec. 21. Four minor candidates in the race -- two rightists and two extreme leftists -- could pick up enough of the vote to deny Sunday's winner an outright majority victory.