The reason why water can "run uphill" in a tree is a phenomenon known as "capillary action."
Basically, the idea is this. Water tends to stick to the sides of containers it is in. When it does this, there's a little bit of water that pulls up the side of the container a little higher than the surface of the rest of the water. This water is called a "meniscus." If you have a container that is very thin, the meniscus on one side will touch the meniscus on the other side. When that happens, you essentially have all the water trying to pull itself up the side of the tube.
Trees have little tubes called "xylem" in them. They're thin enough that the water in them does what I just described. And that's how it works. Check out the link for a more detailed explanation.
Water along with minerals dissolved in it is able to rise up the stem to various parts of a tree, against the force of gravity because of a phenomenon called capillarity or capillary action. This phenomenon refers to tendency of liquids to be dawn up very narrow passages called capillaries.
Capillarity occurs because of the forces of attraction that exist between molecules. Different types of molecules attract other molecules with different magnitude of forces. The force of attraction that exists between molecules also depends on the distance between molecules.
Water and other liquids are drawn up in capillaries because the molecules of wall of the capillaries exert greater attraction toward molecules of the liquid than the force that exist between the molecules of the liquids. This causes the liquid to be drawn up the capillary. Narrower the size of the capillary cross-section, smaller is the distance between the the walls of capillary and liquid at the center of capillary, and greater the inter-molecular attraction between liquid and capillary walls. Therefore narrower the capillary, greater is the extent to which liquid will be drawn up the capillary action.
We can observe the phenomenon of capillarity in many things that we regularly come across. Fir example, the clothes we wear are able to absorb the perspiration easily because of capillary action, as our clothes are made up of very fine fibres that form capillary passage between them, You can observe the action of capillary action by dipping a corner of a piece of cloth in water, You will find that some part of the cloth not dipped in water also gets wet due to capillary action.
Some liquids like mercury have greater inter-molecular attraction than the attraction between liquid and capillary walls. In such cases the liquid is forced out of a capillary rather than drawn in it. This is the reason why the mercury in a common mercury thermometer does not enter the narrow, capillary passage of thermometer, used for indicating temperature. unless forced in because of rise in volume of mercury with increasing temperature.