Atoms contain positive protons in the nucleus and negative electrons around it. The protons cannot leave the nucleus easily, so when two surfaces are rubbed together it is electrons that are transferred from one surface to the other.
The surface that gains electrons has more negative charge than positive charge, so it becomes negatively charged. The surface that loses electrons is left with more positive charge, so it becomes positively charged. For example, when a polythene rod is rubbed with a cloth, electrons move from the cloth to the rod. The rod becomes negative and the cloth becomes positive. The two charges are equal in size but opposite in sign, so the rod and cloth attract each other. This is attraction.
A gold leaf electroscope shows this. It has a metal cap on a metal stem with a thin gold leaf hanging from it. When a charged rod touches the cap, charge spreads over the cap, stem and leaf. The stem and leaf now have the same charge, so they repel each other and the leaf rises. If the rod is only brought near, electrons in the metal are pushed or pulled along it and the leaf rises, but it falls again when the rod is taken away.