Whole books have written on this subject, so I will provide a basic overview, distinguishing between the basic Catholic view and the fundamental Protestant view first advanced by Martin Luther.
Catholics and Protestants agree that God’s grace is fundamental and indispensable to our eternal salvation as Christians. And that initial justification—i.e., when we first come into relationship with Jesus Christ—is a completely unwarranted divine gift (John 15:16; CCC 1989-92).
In short, the Church teaches that God inwardly heals and transforms us by his grace, making us children of God (CCC 1262ff.). This is initial justification, which takes place in baptism. So baptism gives us a share in divine love or “righteousness,” an infused “theological virtue” which enables us to become like Jesus and do his will in a lovingly obedient way (CCC 1991). Baptism restores our communion with God and is the beginning of our salvation, the first step on a lifelong journey.
Through initial justification, from the Catholic perspective, God obligates us to abide in him (John 14:15) and grow progressively in holiness (see Matt. 5:43-48). This progressive growth after initial justification is known as ongoing justification or sanctification. In ongoing justification or sanctification, we continue to grow in the theological and human virtues, with Jesus as our model. This is not “works righteousness” or “salvation by works” as the Church’s teaching is sometimes caricatured. Works alone, as the heretic Pelagius was reminded by the Church in the 400s, can never save. And works apart from grace cannot even contribute to our salvation. Indeed, our good works only have “merit”—including graces for ourselves and others to grow in holiness and help attain eternal life—because they are rooted in and aided by Christ’s love (CCC 2006–16), so that we might persevere in God’s grace instead of rejecting his gift of salvation. And if we are baptized after the age of reason, even the choice to receive baptism is a good work, again aided by God’s grace.
Luther believed that justification took place by baptism, including infant baptism, something with which most modern Protestant don’t agree, favoring instead a nonsacramental “believer’s baptism.” In addition, in harmony with many modern Protestants, Luther saw God as a judge who makes a legal declaration about our righteousness, our being free from sin in some sense, but who doesn’t inwardly heal and transform us by his grace, let alone call us to a life of deepening holiness. For Luther, the original sin of our first parents injured human nature so badly that we are “totally depraved,” i.e., incapable of doing any good at all, or at least not able to do good works that impact our eternal salvation. Indeed, a fundamental plank of Luther’s soteriology is that man’s will is enslaved. From this conviction comes Luther’s doctrine of “justification by faith alone,” meaning our “good works” cannot possibly impact our eternal destiny, and that only by a total repudiation of God (loss of faith) can we lose our salvation.
For Luther, the baptismal “regeneration” St. Paul taught (Titus 3:5) means the removal of the eternal punishment of sin through the justifying faith associated with baptism, and thus it opens heaven to the justified (Martin Luther, The Large Catechism, “Holy Baptism,” nos. 41–46, 83). However, a justified person’s human nature remains totally depraved for Luther, and original sin and an individual’s personal sins are not blotted out; so communion with God is restored but in a lesser way than our first parents originally enjoyed. One needs to keep these distinctions in mind when Luther teaches that Baptism brings about the “forgiveness of sin.” (Ibid., nos. 41, 86).
Because Luther believed man’s will was enslaved, when God is “in the saddle” vs. the devil, man can perform works of sanctification, whereby the Holy Spirit makes us more like Christ in all we think, desire and choose. But if the devil prevails, man inevitably chooses wrongly.
For more on this topic, see Tim Staples article, “Justification: Process or One-Time Deal?” and Mark Brumley’s article “Is Justification Ongoing?” I also recommend my book What Did Jesus Do?: The Biblical Roots of the Catholic Church, particularly the chapter “‘What Must I Do to Be Saved?:’ Successfully Navigating the Highway to Heaven.”