The primary example of dramatic irony occurs in Act 4, scene 1, when Portia disguises herself as Balthazar, the lawyer—the audience knows this is the case, but no one in the court does (except Nerissa, who is also in disguise). Doctor Bellario, Portia's cousin and a lawyer himself, writes of Balthazar in a letter to the Duke, “I never knew so young a body with so old a head." This description alludes to Portia's disguise as both a male lawyer and a young person of great prudence. Her deception carries into Act 4, scene 2, when she (still disguised) persuades Bassanio to surrender his wedding ring to her; it continues in Act 5 when she feigns outrage over her husband's betrayal.
Portia, it seems, is always on the cusp of two different roles: she is known as a good Christian woman, but she is prejudiced; she preaches mercy in court, yet exhibits none; she inherently has less power because she is a woman, but inherently has more power than others because she is very wealthy. Such tension exists throughout the play, as practically every character is filled with contradictions and seems to have at least two sides. The play's use of dramatic irony regarding Portia's identity brings those tensions to the forefront.
When the Prince of Morocco arrives to partake in the casket game, he implores Portia not to judge him based on his darker skin tone. In an instance of dramatic irony, Portia then replies,
In terms of choice I am not solely led
By nice direction of a maiden’s eyes;
Besides, the lott’ry of my destiny
Bars me the right of voluntary choosing.
But if my father had not scanted me
And hedged me by his wit to yield myself
His wife who wins me by that means I told you,
Yourself, renownèd prince, then stood as fair
As any comer I have looked on yet
For my affection.
Portia claims that she does not judge suitors based on their looks and that, if she did have the freedom to choose her own husband, she would hold Morocco in as high esteem as any other man who has come to win her hand thus far. But while Morocco interprets this sweeping speech as earnest and reassuring, the audience interprets it as sarcastic, remembering how Portia harshly mocked every suitor that Nerissa mentioned in Act 1, Scene 2. This dramatic irony also hints at Portia's racial prejudice, which more fully comes to light when Morocco chooses the wrong casket; as he leaves, Portia retorts, "A gentle riddance! Draw the curtains, go. / Let all of his complexion choose me so." In this context, Portia's earlier sentiment to the Prince is even more clearly sarcastic, as she evidently does judge people based on their race. These lines therefore help to establish the dynamics of the entire play: in Portia's society, those in power (such as herself, a Christian of significant wealth), are customarily self-satisfied and antagonistic towards those different from themselves.