They believed, and the Scripture says it was counted as righteousness (Rom 4:3). No one is saved by works (Rom. 10:9). They were saved just as we are today, by faith in the promises of God.
Hebrews 11 describes examples of faith by Old Testament saints. By faith, Abraham obeyed God’s call to go to a new land. By faith, Sarah had the child of promise though she was beyond the age of childbearing. By faith, Moses chose to identify with the people of God and experience suffering rather than accept the privileges of Pharaoh’s household. Old Testament saints were saved because they believed in God’s promise for them that He would provide, ultimately through the gift of His Son.