TEL AVIV—Prime Minister Benjamin Netanyahu is waging a fight against small right-wing parties that is almost as fierce as his campaign against a strong challenge from his left, illustrating the complex math behind his re-election effort.

Mr. Netanyahu has often relied on small right-wing parties that support settlers, religious laws and security to form governments in the past decade, using Israel’s freewheeling parliamentary system to his advantage. Forty parties are vying for the 120 seats in the Knesset—ranging from mainstream...