A gripping and beautifully produced surprise, "The Scarlet and the Black," the three-hour CBS film at 8 tonight on Channel 9, is movie-quality movie all the way, more sophisticated and accomplished as filmmaking than ABC's upcoming "Winds of War," and all the more rivetingly suspenseful because it is based on the story of a man who really existed.

Gregory Peck, making his second TV film appearance of the season (the first as Abraham Lincoln in the CBS miniseries "The Blue and The Gray") plays a tower of strength toweringly; he is Msgr. Hugh O'Flaherty, who came to be known during the last year of World War II as the "Scarlet Pimpernel Priest" for his heroic derring-do in helping thousands of Allied prisoners escape from occupied Rome and the persecution of the Gestapo.

His story has been turned into a warming, rallying and enjoyably nerve-wracking film by writer David Butler (who adapted a book by J.P. Gallagher) and director Jerry London, who knows how to turn the screws of tension just about as tight as they can go. This is a class production all the way, filmed magnificently on location in Rome by the renowned cinematographer Giuseppe Rotunno and scored by inventive composer Ennio Morricone. The producer is Bill McCutchen; stint did he not.

The first impression of Peck one may have is how splendid he looks in the black garb of the church. He has worn the robes before--in the 1944 film "Keys of the Kingdom"--but has never looked quite so authoritative and commanding. Peck's Irish accent may not convince everyone, but his performance really is in the nature of a triumph. Robert Mitchum lopes through "Winds of War" being Robert Mitchum; Gregory Peck strides grandly through "Scarlet and Black" being Gregory Peck. The number of actors who can command attention so compellingly is dwindling, but more than that, Peck is unique in his ability to symbolize rightness of thinking and decency, and he does it without overdoing the adorability bit.

But the monsignor's principal adversary in the film, an SS colonel named Kappler, is played by an actor with impressive reserves as well: Christopher Plummer, who succeeds in bringing new, subtle nuances to the kind of role that, after so many films about Nazis, can't be easy to play with any sort of originality. We are able to see Kappler as more than depraved, and the script and Plummer's characterization even allow him a kind of pathos. Director London's most effective manipulative coup has Kappler contemplating O'Flaherty through the sites of a rifle--a brilliantly edited, scored and directed moment of prolonged pure hell.

The story begins in September 1943 and ends as the Allies liberate Rome. O'Flaherty risks his life repeatedly to provide aid and comfort to escaped prisoners of war. As the film opens, Kappler has arrived in Rome to take command and has a white line painted around the Vatican, whose neutrality and sanctuary the Third Reich is begrudgingly observing. O'Flaherty continues to cross over the line even when it becomes clear the Gestapo will torture and murder even a priest.

Butler's screenplay treads delicately in the controversial area of the Vatican's stand on Nazi treatment of the Jews. The role Pope Pius XII played, or allegedly neglected to play, in protesting this most monstrous inhumanity became a subject of debate, started in the '60s by Rolf Hochhuth's accusatory play "The Deputy." Later, an Israeli scholar produced evidence indicating the pope had spoken out in protest but, more importantly, had worked behind the scenes to help save as many as 700,000 Jews from Hitler.

In the film, John Gielgud plays the pope as a mildly confused but sympathetic figure. He repeatedly warns the monsignor that he cannot protect him should the Gestapo produce evidence of O'Flaherty's involvement with the underground, but when the chips are down, he does in fact come to his defense. Butler has the pope ask, on the matter of insisting the Vatican remain neutral rather than officially anti-Nazi, "Was I wrong?" and say, "Well, perhaps I could have done more."

In the film version of this story, O'Flaherty could not have done more. Indeed, when Rome's Jews are ordered to ante up an "indemnity" of 1 million lire plus 100 pounds of pure gold for the Reich, O'Flaherty helps raise the funds. When the Gestapo sets up guards around the Vatican to keep him in, the monsignor disguises himself as a peddler, a peasant, a nun, in order to get out into the city and do his work. When a Vatican priest is captured with money intended to help in the effort (the priest is played by Raf Vallone, who also played a priest in Otto Preminger's "The Cardinal"), O'Flaherty disguises himself as an SS officer to get access to the priest in his cell and hear his last confession.

Now, how much of this really happened? According to an Associated Press obituary of O'Flaherty, he helped disguise many of the escaped prisoners that he had stashed away in apartments throughout the city, though there is no mention of donning disguises himself. In the film, O'Flaherty tricks Kappler into signing an order freeing one prisoner by asking for his autograph at the opera; according to AP, it was an escaped British Army officer who actually did that.

But this leeway with strict fact can be rationalized as merely compressing story elements. There is no question that O'Flaherty was a hero, a pillar, a great man--he was subsequently honored by both England and the United States for his valor. "The Scarlet and the Black" can be seen not as a docudrama, but as a fable about a battle between clear good and absolute evil, and a reminder that there have been such battles, even among the ambiguities of the 20th century. Occasionally, right even won out. This is, down to the two final twists that conclude the story, rousingly satisfying television entertainment--nothing less and, at times, something more.