In this article we study deformations of a holomorphic foliation with a generic non-rational first integral in the complex plane. We consider two vanishing cycles in a regular fiber of the first integral with a non-zero self intersection and with vanishing paths which intersect each other only at their start points. It is proved that if the deformed holonomies of such vanishing cycles commute then the deformed foliation has also a first integral. Our result generalizes a similar result of Ilyashenko on the rigidity of holomorphic foliations with a persistent center singularity. The main tools of the proof are Picard-Lefschetz theory and the theory of iterated integrals for such deformations.