When you submit an offer to purchase a property, you will be asked to provide (either with the offer or after the offer is accepted) a purchase deposit. The deposit is generally 5% of the total purchase price, but can be more or less depending on the transaction itself. Your purchase deposit is held in trust by the listing brokerage until the closing date of your transaction.
The deposit amount is applied towards your down payment. For example... If your total down payment due on closing is $50,000 and you gave the seller a $10,000 deposit when your offer was accepted, you would only be paying the balance (or $40,000) out of your pocket on closing to your lawyer as the remaining down payment.
In the case that the deal falls through in the conditional period (if you're putting a conditional offer), then there is a process where you can get your deposit refunded upon cancellation of the deal subject to seller and broker of record approvals.