Sorry, you can't 'rescue' a relationship while the other is sabotaging it. I wish it weren't so, but that is the reality.
If he were in effective therapy and was making real improvement applying the therapy in his life long term and not just a little to fake it for the professionals, then it might be different.
What you need is to determine how to protect yourself. In the future it won't look good to have an order restraining you or protecting him. Some people have even lost jobs or job opportunities. Evidently you don't have children together so that means you don't have to be in contact with him.
At the hearing, whatever it is about, understand that he WILL throw you under the bus, so to speak. He will almost certainly portray himself as the Victim and you as the Abuser. Hopefully, he has no documentation to support such claims. Understand that for a person with BPD, all past relationships are blacklisted.
You didn't mention what the litigation is about. If he's trying to paint you as an abuser stalker, or harasser then one tactic is to tell the court that you've come to realize the relationship was dysfunctional, you tried to make it would but it just didn't and it's time for the two of you to go your separate ways. Why do I say that? If the professionals see two people needing intervention repeatedly, then they know they'll keep coming back as repeat litigators and they won't be as helpful as they would have been if one said "It's over. I'm keeping my distance from the other. I'm Moving On with my life and want the other person to do the same."
Have the read
The Bridge? Follow the link. You can't save someone if the person doesn't want to be saved.
Do you still want to help him, feel compelled to help him, even if it harms you? (It has already!) Then ponder well whether you're being objective. Do this to shift mental gears. Imagine you have a dear friend who has a BF who has ripper her life apart and and even made allegations against her. Her life is like he! on earth. She still wants to 'help' him even though there's no indication it will ever get better, odds are it will get even worse as time goes on. What advice would you give your dear friend? Hmm?
Your mental attitude when you go into court is to look for ways to disengage from him with as little harm to you. Present solutions to the court, don't let him paint you as the Problem. Be the Problem Solver.
If you still want to 'fix' or 'save' him, then buckle your seat belt, the scary roller coaster ride isn't over.
If you don't have a counselor to help you Let Go and Move On with your life, then you should find one.