The Catechism in Questions & Answers

545. What statements does Holy Scripture make concerning help for the dead?

In 2 Maccabees 12 there is an account of men who had served idols and fallen in battle. Their comrades prayed that they would receive help for the sinful condition of their souls. They also collected money with which to buy sacrificial animals in order to bring an offering of atonement.
The biblical basis for dispensing sacraments to the departed is found in 1 Corinthians 15: 29: in Corinth, living persons were baptised for the dead. This practice was once again adopted by the Apostles of the modern era. From this developed the divine services for the departed that are celebrated today.