At the end of the Golem and the Jinni, all our characters come together in an epic showdown of good and evil. Well, in a showdown of Jinni and Golem versus selfish wizard—it's not like the fate of the world is at stake or anything.
We find out that Yehudah Schaalman is the evil Wahab ibn Malik reincarnated, and he'll continue to be reincarnated as long as the Jinni is alive. The Jinni tries to kill himself, but the Golem, who knows all about self-destruction, saves him. They have a showdown with Schaalman ibn Malik, or whatever we call him, and Ibn Malik binds the Golem to himself as her master, and tries to get her to trap the Jinni in the flask. However, Saleh, who follows them, ends up trapping ibn Malik in the Jinni's flask.
It's the perfect, ending, really. The Golem gets a master that she doesn't have to listen to (him being trapped inside a bottle and all) and the Jinni doesn't have to kill himself. Poor Saleh dies in the scuffle, and the Golem has to deal with the guilt.
The good news is that the Golem and Anna make up (after Anna's blackmail episode) and the friends seem to really support each other through tough times. Plus, the Jinni grows to appreciate the life he now has in New York. Even though he visits his home, the Syrian Desert, he only does so to deposit the flask full of ibn Malik there in the care of other jinnis. He then decides to return to New York, which is now his home.