I found an uncommonly large black ant and put it in a glass cup to observe it. It initially had a lot of trouble climbing vertically by any amount. However, I noticed it paused and when I looked closely, it seemed to run its front legs quickly between its mandibles, and it looked as though it secreted some kind of orange liquid through its mouth. After it did this and climbed again, it climbed a little bit further up the cup, but fell down again.
Then, it repeated the process of pausing and running its front legs between its mandibles. After this, it tried to climb again and I saw it was able to climb a little bit further than it did after the first run before falling down, though I didn't think to measure the exact height on a drinking glass. I saw it repeat this process yet again, and it stuck to the cup even better and climbed even higher before inevitably falling, and I assumed it would continue this process indefinitely until it was able to climb out of the cup, so I threw it back outside.
I would hypothesize that the ant was coating its legs with its own saliva which has evolved to be sticky for situations like this, seeing as how it so quickly exhibited the mental aptitude for recognizing its climbing challenge. But, I'm not biology expert. Perhaps its legs already inherently possess all stickiness ability it needs, and it is only that its legs were dirty or covered with water.