suggests that
people or groups with a common opponent may form a temporary alliance despite their other differences. Such an alliance does not necessarily imply genuine friendship.
Two rival parties cooperated to oppose a policy that threatened both of them. The enemy of my enemy is my friend.