If you can't negotiate with your enemies' enemies, negotiate with your enemies. Assuming that they are rational sentient beings, if you put forward a good argument you can often convince them to back off.
There are many ways to do this.
1. Show them that you are not a good target. Especially if it's an illogical attack, point out that you can stalemate them or 50-50 with them so that they could be incredibly unproductive and that a conflict would merely cause stagnation while other countries grow.
2. Give them a better target, point out that someone near them is completely open for invasion, and offer to help them. Be reasonable with this.
3. Convince them that you are NOT a rational thinker, and that if they attack you, you will abandon reason, and devote all your resources towards thwarting him, and will see to the end that they are defeated.
4. Convince them that players around them will attack them, or are untrustworthy. Whether this is true or not is up to you. ; )
In the end, even if you can tactically fend them off, you should still use diplomacy, because even if you think you have them stuck, they can always use diplomacy to break through with the help of others. That's the name of the game.