We develop the method for constructing Lax representations of pdes via twisted extensions of their Lie algebras of contact symmetries by generalizing the construction to Lie-Rinehart algebras and present examples of application of the proposed technique.