Inside the ant aggregation the ants grip each other using their feet and jaws.Ants are able to grab onto anywhere on another ants though the strongest connection are foot-foot connections. In the images below we see a jaw-leg connection and a foot-leg connection.
These images are from
Foster, P. C., Mlot, N. J., Lin, A. & Hu, D. L. Fire ants actively control spacing and orientation within self-assemblages. The Journal of experimental biology 217, 2089-2100 (2014).