The energy of rubbing or friction gives extra energy to electrons. This allows some of them to break free from their nuclei and wander off on their own.
It is known as "separating charge". Some electrons pass or transfer from one material to the other.
When a glass rod is rubbed with silk, it acquires positive charge and by convention silk will acquires some amount of negative charge.
Similarly, when a plastic rod is rubbed with fur it acquires a negative charge, and the fur itself is found to acquire a positive charge.