In Act 3, Emilia is clearly loyal to her husband. She steals the handkerchief because Iago bade her to and she remains silent when Othello questions Desdemona as to its whereabouts. But at the end of the play in Act 5, Emilia's loyalties change. She cares not for Othello's sword, and she will vouch for Desdemona's faithfulness even if it means her own death. When she finds out that Iago is the instigator of the slander against her mistress, Emilia does not hesitate to tell the truth about the handkerchief even if it means that she will "ne'er go home again.' Emilia becomes heroic at the end of the play, and she is the one who makes Othello understand the wrongness of his action, clears Desdemona's name, and exposes Iago for the villain that he is. She is loyal to Desdemona, wanting to die by her mistress's side, but she is more loyal to Truth.
Emilia also hints at her loyalty potentially being to her own self first (though she has played the game of the obedient wife throughout the majority of the play) in Act IV, scene iii. She gives a very famous speech about wives and what the "owe" their husbands, and it exposes, I suspect, her true feelings about who she will ultimately protect when all the chips are down -- herself.
...Let husbands know
Their wives have sense like them: they see and smell
And have their palates both for sweet and sour
As husbands have.
She certainly, it seems, feels free and able to speak her true mind in Desdemona's presence, unlike her behaviour with Iago. So, I would say that she also feels a strong loyalty to Desdemona, and though it is too late to save her mistress, does indeed defend her name at the end of the play.
There are many questions and implications here. Indeed, Emilia does hold loyalty to Iago as she unwillingly participates in his scheme. Yet, she does assert her own voice against him and is the only one who really is free from his manipulation. When she understands the truth of what is happening, she is the one who speaks out and seeks to establish some semblance of moral order in a setting where Iago and others have done significant damage to it. Her commitment to clearing Desdemona's name, asserting the truth to Othello, and repudiating her husband's actions are where her loyalty does lie in the end when she is aware of the full magnitude of what is happening. The "twenty lives" line is a testament to this commitment.