The details of payments systems are complex, and vary by country. I am slightly familiar with how it works in Canada, and I believe that the principles would not be radically different in other developed countries. Here’s a primer on the Canadian payments systems: link.
The advantage of Canada is that there are no reserve requirements, so it’s easier to explain. If you look at the balance sheet data published by the Bank of Canada, the Canadian banks normally have a balance of \$0 at the central bank at the end of the day. In fact, that is what is expected. (In practice, there are small misses of the zero balance; a lot of money sloshes through the payments system.) In a country with reserve requirements (like the U.S.), banks would like to have a target balance equal to their required reserves. (At present, the Fed has forced excess reserves into the system.)
The amount of interbank transactions are very large. They send amounts back and forth on the payments system based on various transactions - their own, and client transactions. The job of a Canadian bank Treasurer is to make sure that the net balance of all payments ends up at \$0 at the end of the day, so that the net position at the Bank of Canada is unchanged. (In a country with reserve requirements, they will want to hit at least the required reserves level.) They will achieve this by any number of methods:
- issue new securities;
- borrow/lend in the interbank market;
- buy or sell securities (mainly government bonds);
- borrow/lend through repurchase agreements (repos);
- if all else fails, run to the central bank and borrow against their assets. This option is greatly frowned upon, and will prompt an investigation from regulators as to why the bank cannot borrow in the markets. (This is termed a “lender-of-last resort” operation, and should only be necessary in a crisis).
(Since you asked about bank lending in particular, it is achieved by Bank A wiring money to Bank B through the payments system, in exchange for a contractual obligation to make a reverse future operation with interest.)
The multiplicity of options means that we cannot trace exactly what happens when customers transfer funds to someone at another bank; all we know is that at the end of the day, all of the bank’s transactions with the payments system should net to zero.