Water molecules have cohesion forces attracting them to each other due to the hydrogen bonds they have.
When water molecules come in contact with some charge surfaces like glass or the lining of a xylem vessel, they stick to it by the adhesion forces .
Because of the charge on the surface, the water molecules are attracted to the other upper part of the surface where there is no water sticking to it. As a result, water molecules climb up a little.
These water molecules are still connected to other water molecules below them by the hydrogen bond (adhesion) and hence tend to pull them up as well. The process repeats till a water column goes up inside the tube.
This process is limited by the diameter of the tube as the bigger the diameter the smaller the water column that can climb up. The reason is that the bigger the column, the more water molecule that are to be pulled up and hence the more the effect of the gravity which is opposite in direction to the capillary action.