Gravity is what keeps the pendulum swinging, not what makes it stop. When the pendulum is at the very top of its swing it is motionless for that split second, but it is at its highest point. So it has no kinetic energy (KE), but it does have potential energy (PE). On the way down it speeds up and trades PE for KE, thanks to gravity pulling it down. At the bottom of its swing it is moving as fast as it ever will, but is at its lowest point. So it has all KE but no PE. And on the way back up it slows down (again, thanks gravity) and trades speed for height. So again, back at the top of its swing it is all KE and no PE.
In in ideal (ie, no friction; lossless) world, the pendulum would swing forever, repeatedly trading KE for PE and vice-versa.
But in real life there is friction, and friction causes losses of momentum (mass * velocity). In the case of the pendulum the two sources of lossses are air resistance (friction between the pendulum and the air it's moving through) and the friction at the pendulum's pivot point (the hinge). The air resistance is at its maximum when the pendulum is moving fastest (the bottom) and zero when it's stationary (at the top). The friction at the pivot point consists of static (not moving) friction and dynamic (moving friction). When the pendulum is at the bottom of the swing it's moving fastests, so the dynamic friction is greatest and there is no static friction. At the top of swing it's not moving, so there is no dynamic friction but the static friction must be overcome for the pendulum to start moving again.
When you add the KE and the PE you get your total energy (TE). Without friction the TE for the system would remain constant and just trade back and forth KE for PE, as mentioned before. But in real life, with each cycle of the pendulum, frictional losses take a little bit of TE away. So eventually the pendulum will stop entirely.
So to wrap it all up, the variables that will eventually cause the pendulum to stop are static and dynamic friction, in the form of air resistance and the friction at the hinge. Gravity does not make the pendulum stop.