This is accomplished by first executing the unlocking script and then executing the [locking script](/protocol/blockchain/transaction/locking-script) for the UTXO referenced by the transaction input.
For more information about how script execution works, see [Script](/protocol/blockchain/script). For information on how signatures (which typically go in the unlocking script) are generated, see [Transaction Signatures](/protocol/blockchain/transaction/transaction-signing).