It is a bit complicated.
Summary: Korra made an amplified spiritual projection to fight UnaVaatu, however she lost. Then, spiritual projection of Jinora awakened Raava inside the Vaatu so Korra became connected with Raava again. After that, she spirit bended UnaVaatu.
Korra: Raava is gone. I am not connected to her spirit anymore.
Tenzin: I am not talking about Raava. Raava is not who you are.....The most powerful thing about you is not the spirit of Raava, but your own inner spirit. You have always been strong, unyielding and fearless.
Here, we establish that Korra is strong without Raava as well. Inner spirit plays crucial role in Korra's last defence against Unalaq.
Tenzin: You have to help them Korra.
Korra: How? They're half way around the world.
Tenzin: Do as the ancients did. Connect to the cosmic energy of the universe. Don't bend the elements but bend the energy within yourself.
So, Korra bent the energy within herself to amplify her spiritual projection.
Raava: He cannot destroy light anymore than I can destroy darkness. One cannot exist without the other. Even if I were to defeat Vaatu in this encounter, darkness would grow inside me until he emerges again. The same will hold true if Vaatu defeats me.
Wan: That doesn't sound so bad. Even if Vaatu wins, you'll still come back.
Raava: Yes, but you will probably not survive to see it.
This quote, and many other quotes in the same season suggest that Raava is not dead but alive within Vaatu. Naturally, it would reemerge after some time but it would take more than the span of a human life. I guess it is implied that darkness will rule the world until the next harmonic convergence, which is an event that happens every 10.000 years.
Jinora comes into play here. She accelerates Raava's emergence. And Korra pulls Raava out of Vaatu and then performs spirit bending on UnaVaatu. Spirit bending balances a spirit's negative and positive energy. This part is not very well established within the series, but Vaatu is no longer a prisoner in the Tree of Time at the end of the episode. Korra says something that gives a hint:
Korra: I'm sorry about your father. But he was already fused with Vaatu. I couldn't save him.
So, at the end of spirit bending, Korra might have killed Vaatu. If she did, he will reemerge after some time, inside Raava.