In "Measure for Measure," William Shakespeare wrote, accidentally or by design, the trickiest sort of a play-a comedy with tragic relief. The work gets an alternately somber, sardonic and, in the last act, rousingly exuberant treatment tonight as the fifth of "The Shakespeare Plays" to be aired by PBS this season.

"Measure for Measure," at 8 o'clock on Channel 26, benefits immeasurably from the key performances of two women. Kate Nelligan is the image of idealized faultlessness as Isabella, interrupted in the pursuit of her religious vows at a convent by the nasty news that her brother Claudio is to be executed for the crime - or the sin or whatever - of fornication with a woman to whom he was not married.

For this he is paraded through the streets and then chucked into a grimy cell at ye local jaile.

Jacqueline Pearce, meanwhile, voluptuously and charismatically represents another aspect of womanhood; as the once-wronged Mariana, she substitutes herself for Isabella one naughty night when an unscrupulous nobleman demands Isabella's virginity for himself as payment for her brother's release.

Many of the male roles are tossed off handily as well - Tim Pigott-Smith as that cad Angelo, John McEnery as the insufferably foppish Lucio, and Kenneth Colley as Duke Vincentio, who spends much of the play disguised as "a very saucy friar" in order to ascertain the pervasiveness of corruption in old Vienna.

"Quite athwart goes all decorum," is the dukes's little weather report on the city's moral condition.

Whether Shakespeare embarked upon a diatribe and changed his mind mid-play, or whether he intended to lead his audience into what appears a moral fable about hypocrisy and injustice and then surprise them with the treat of a farce, we do not know. But mysteriously and for reasons probably built in by that old crowd-pleaser of Avon "Measure" works splendidly and gladdeningly, and the fluid touch of director Desmond Davis serves it well. CAPTION: Picture, Kate Nelligan as Isabella