A 30-second television advertisement was being played often here in the final week of the Democratic mayoral primary, and it nicely captured the curiosities of race in this campaign.

A candidate is shown moving smartly through a pulsating crowd of black supporters. They chant his name, he pumps hands and busses faces and the upbeat music of Kool and the Gang's hit song, "Celebration," thumps in the background.

"This campaign didn't divide Philadelphia," an announcer says in a tone of unabashed self-congratulation. "It brought us together."

The candidate is Frank L. Rizzo, and the spot is the grand finale of a strategy that has seen him appeal for white votes and history's redemption by demonstrating to blacks that he has no fangs.

Whether it works will become clear Tuesday, but the odds seem long. Philadelphia's 888,000 Democratic voters, 44 percent of whom are black, will choose between Rizzo and W. Wilson Goode, 44, the former city managing director who has led from the start in his quest to become the city's first black mayoral nominee.

It is not the black voter who has been killing former mayor Rizzo's hope in this race; it's the white voter who abandoned him years ago for being a racial polarizer. His spots are designed to recapture those disenchanted whites.

While Rizzo has been defanging his old image in the most expensive media blitz the city has ever seen, Goode has been spending almost as much refanging it.

Goode's television ads show old pictures of Rizzo as police commissioner supervising a strip-search of Black Panthers and Rizzo the mayor arriving at a crime scene with a night stick protruding from his cummerbund.

They show Rizzo hooked up to a polygraph and flunking a test about whether he offered a patronage deal, and they show 10,000 Philadelphians standing in line in the rain waiting to apply for a few hundred City Hall jobs that Rizzo had secretly given in advance to political cronies.

"Philadelphia has crossed a bridge in the last three years . . . and maybe we've left Frank Rizzo behind," one Goode ad concludes.

In the privacy of the voting booth, skin color may indeed turn out to be precisely what this campaign has been about. But the public dialogue of the campaign, on the streets and on the air, has been about something else. It has been about whether Frank Rizzo can turn back the clock.

Goode supporters are convinced he cannot. Allen Hornblum, Goode's campaign coordinator for the heavily white, middle-class Northeast section of the city, said:

"Frank Rizzo was a man for his time, and those times have passed. He came out of an era of college uprisings, of blacks moving into white neighborhoods, of burning cities and hot summers. People were scared, and he appealed to their baser instincts. The fears are different now; they are about jobs, unemployment. Rizzo comes across as a wooden, one-dimensional figure. He doesn't speak to those fears."

If Rizzo is defeated Tuesday, it will be in a sense his second "last hurrah." In 1978, nearing the end of his second term as mayor, he sought a change in the city charter that would have permitted him to seek a third successive term.

He lost by a resounding 2 to 1, and his retirement has been haunted by that defeat. In the last weeks of the charter campaign, he urged voters to "vote white." Although he uttered the phrase just once, claimed it was a slip of the tongue and immediately repudiated it, it stuck.

Rizzo entered this campaign determined to bury that phrase. "Frank has accomplished everything he set out to accomplish in this campaign," a top campaign aide said recently, even as he acknowledged that the polls make victory appear unlikely. "He wants to show people that he is not a racist."

Many see a touch of melancholy in his effort. Rizzo, 62, can be a riveting street campaigner. He has a huge, radiating physical presence, a salty, rough-hewn personality and an uncanny policeman's recollection for names, faces, episodes, anecdotes.

He had been a barnstormer of a candidate, but his pace this time has been slower. Some campaign days did not start until 11 a.m., and many afternoons were spent in his private office at headquarters, chatting on the phone or in person with old friends. Evenings often included leisurely dinners at the Vesper Club, a favorite downtown hangout.

But behind Rizzo's modest pace lies an organization that shows discipline and verve. Earlier this spring, his camp obtained more than 30,000 Republican registration changeovers in an organized effort.

Goode's organization perhaps even exceeds that of Rizzo. About half of the city's Democratic ward leaders are with Goode as is a volunteer army of about 10,000 street workers to be assembled on election day from 16 staging areas.

For public consumption, Goode operatives said the race will be close. Privately, they believe the only question will be the size of the victory. They are counting on as much as 95 percent of the black vote and 25 percent of the white vote.

If the victory is by about 8 percentage points or more, the Democratic Party organization, splintered and broke, is expected to fall in behind Goode, along with the business community, which has contributed substantially to his campaign war chest of more than $1.5 million. In a city that is Democratic by 5 1/2 to 1, the Republican candidate must be considered quite a long shot, regardless of skin color.

The GOP is involved in its most spirited primary in a generation, matching John Egan, a stockbroker and converted Democrat anointed by local GOP boss William Meehan; Charles Dougherty, a former congressman with a strong base in Northeast Philadelphia, and former basketball star and city controller Thomas Gola.

In recent weeks, Gola's campaign is thought to have lagged, leaving the race to Egan and Dougherty.