Antonio's sad predicament ends happily for him when Portia, Bassanio's betrothed, appears in disguise and provides the perfect defense for Antonio, saying that Shylock can have the pound--no more, no less--of flesh but not one drop of blood. The Duke agrees with the defense, so Antonio is spared since the terms surrounding the extraction of the pound of flesh are impossible to meet.
Portia then introduces another law that states that any foreigner--Jews were foreigners and not afforded citizenship--who endangers the life of a citizen of Venice shall lose half his wealth to the intended victim, the other half to the Duke and that the Duke will decide to spare his life or take it. Shylock's possessions are divided according to this law, and the Duke spares Shylock's life but decrees that he renounce Judaism and convert to Christianity--a sentence worse than death to Shylock.
The loving couples are all united at the end in Belmont, including Lorenzo and Jessica, a Gentile and a Jew. However, it is unfair to say that Antonio's sad story ends happily for all because Shylock's sad story--incited by Antonio's lack of Christian charity, love, kindness and humility--ends in bitter living death.