This depends a lot on both the type of charge and the systems involved.
First rule of using debit cards is that you have to have the money to use it. That's the main difference between credit cards (where you're given a credit line) and a debit card (where you're debiting your bank account directly). As such, banks have to go at great length to ensure you're not ending up overdrawing your account.
What it means is that any transaction using your debit card will be immediately communicated to your bank, and the amount the merchant communicated will be "set aside", or put on hold, so that the bank knows not to let you use it again in a different transaction.
You've got a great explanation from the user 'Justin Cave' about holds where the transaction amount is not known ahead of time. But it also happens when the transaction is known. In fact, from the banks' perspective it doesn't matter, the process is the same.
The transaction itself clears (or posts, different places use different terminology) at a different time. Sometimes the process is online, sometimes it is done in batches during the daily (or rather nightly) processing. Sometimes the transaction has to go through several different steps and be processed at different institutions. This is especially true for international transactions, but not always.
How you see it reflected on your account may not necessarily match how it is actually processed. For example, you may see a transaction, but it is actually a hold. How it is presented to you depends on the bank itself.
Once the transaction clears the bank reconciles it with the hold (matches the merchant, time, amount) and removes the hold. Sometimes this doesn't happen, and there could be many reasons, some examples:
- Transaction couldn't be reconciled. You may end up with the transaction posted, but the hold remains because the bank couldn't match them. This happens rarely. Sometimes it happens when the merchant puts a hold ahead of the transactions on a much larger amount (rental cars, hotels usually do this). You'll need the merchant to cancel the hold.
- Transaction never happened. For example, you swiped the card at the gas pump and then changed your mind and didn't actually fill any gas. The hold then will remain until either the merchant communicates cancellation or it expires (depending on the bank - may take weeks)