Osmolarity of the kidney’s interstitial fluid increases from the cortex to inner medulla. This ensures that there is a concentration gradient that allows for osmosis to take place along the kidney tubules in a kind of countercurrent flow exchange system. This way most, amount of water can be reabsorbed.
The same occurs in the loop of Henle in a process called countercurrent multiplication. The descending loop actively takes up solutes hence making the blood plasma in the the vasa recta highly concentrated. In the ascending loop, therefore, water in the tubules is reabsorbed by osmosis hence making urine more concentrated as it gets to the bladder.