CCC 1256 The ordinary ministers of Baptism are the bishop and priest and, in the Latin Church, also the deacon.1 In case of necessity, anyone, even a nonbaptized person, with the required intention, can baptize2, by using the Trinitarian baptismal formula. The intention required is to will to do what the church does when she baptizes. The Church finds the reason for this possibility in the universal saving will of God and the necessity of Baptism for salvation.3
1 Cf. CIC, can. 861 # 1; CCEO, can. 677 # 1.
2 CIC, can. 861.2.
3 Cf. 1 Tim 2:4.