After you knock Bastila's life down low enough, she'll start a conversation with you. There are four of these in total, one before the fight, two during, and one that will end the battle. (Well, hopefully.) If you're intent on bringing Bastila back into the fold, then you'll need to follow the script here closely; if you veer off, even to what sometimes seems like it's nearly a synonym for one of the choices here, Bastila may decide to remain with the Dark side at the end of your conversation, and you'll need to reload. Reloading is annoying, so just pick these choices and get it right the first time.
Before the fight:
"I'll never give up on you, Bastila."
First interlude:
"I'm as strong in the Light side as I ever was in the Dark."
"Malak will never let you become that powerful."
"You're dooming yourself to an endless cycle of death and destruction."
Second interlude:
"Then strike me down, Bastila. I will not defend myself."
"You are not evil, Bastila."
Third conversation:
"Now you see the Dark side is not stronger than the Light."
"There's no need for me to kill you."
"I was redeemed, Bastila."
"You can reject the Dark side, Bastila."
"You did protect me, Bastila."
(Note: if you start seeing persuade options here, and you have a high persuade score, then you should choose these. An unsuccessful persuade is not a good thing, though.)
"Help us defeat the Sith."
"I trust you enough to leave myself open to your attack, Bastila."
"You won't, Bastila."
After that, Bastila should cease attacking you, though she will choose to stay near the Star Forge and use her Battle Meditation to aid the Republic fleet, rather than accompany you to confront Malak.
Dark side players: On the other hand, if you and Bastila have claimed the Sith throne by defeating Malak, the two of you will be paired off with three of his more powerful Dark Jedi. They're tough, but they're not substantially different from the Dark Jedi you've been playing against all game. Stun them to break them up, then kill them when they're defenseless.
After you've killed, converted, or defeated your enemies, friends, or loved ones, head through the door to the south to reach the Star Forge's droid factory. Bastila will remain behind at this point if you're a Dark side character. Head to the far end of the factory, where Malak will appear; your choices in the resulting conversation will get you either a Light side or Dark side shift. He'll lock you in regardless, then activate the machinery here, which will produce eight droids right away, each of which will be replaced automatically when you destroy it.
Have no fear, though, because you can rather easily manipulate the machinery to your own ends. You may have noticed the dormant computer terminals scattered around the room; after the factory is activated, these will switch on and allow you access. There's one beside each droid machine, and you'll need to access each one of them, to either shut the machine off, or switch it over to produce friendly droids that will fight on your side. You'll burn through computer spikes fairly quickly, but don't worry: the cylindrical "spike bins" next to each terminal generate a computer spike every time you destroy one of the droids created by that corresponding terminal. One important note is that it's impossible to use the terminals while you're in battle mode; use the B button to switch to normal targeting, then use the terminal.
After you either shut down all of the computers or switch them to friendly robot production, the elevator to the factory level will open up. Gear up for the confrontation you've been looking forward to since the game began, then step into the lift.