We prove the p-curvature conjecture for rank two vector bundles with connection on generic curves. Our ingredients include new deformation techniques vanishing p-curvatures families of varieties, as well topological criteria finiteness surface group representations in terms simple loops and pairs pants.