As the comments put it, friction is a consequence of the interaction of macroscopic degrees of freedom with the microscopic degrees of freedom, via the electromagnetic force. Clearly, since a very large number of particles would be required for us to 'experience' friction it can be called an emergent phenomenon.
It can be quite a daunting task to derive the friction in case of solids since we will have to take into account the detailed structure of both surfaces and so on. I will try to illustrate the general idea here.
If a moving body ($A$) is in contact with a stationary one ($B$), there would be collisions (or interaction) between their molecules. Consider two molecules, one in both $A$ and $B$ with initial velocities $u$ and $v$ respectively. They come out of a collision with final velocities $u'$ and $v'$. In 3D, to specify all the six components of the final velocities we need six constraints. Four are easily obtained from conservation of momentum and conservation of energy. For the fifth equation we need to note that the microscopic forces are radial and hence all the four velocities lie in the same plane. Sixth equation comes from the exact nature of the interaction (electromagnetic in this case). The problem is hence completely solved.
Assuming both bodies are at the same temperature, the average kinetic energy of the molecules in $A$ will be more than that of those in $B$ by by an amount proportional to the macroscopic kinetic energy of $A$. Naturally, collisions in which molecules of $A$ have final velocity less than its initial velocity would be more probable than the other way around. This is what we model as the 'coefficient of friction'and obviously the preceding argument would not be valid if the number of molecules is not very large.