Moving in a straight line ensures they do not circle back to the dungheap, where other beetles might snatch their prized lump.
The scientists found during field experiments in South Africa that on cloudy nights the beetles wandered aimlessly - but when put in a planetarium showing the Milky Way, they regained their bearings.
"When the Moon is absent from the night sky, stars remain as celestial visual cues," the study's authors said in the report, which was published in Current Biology.
"Nonetheless, only birds, seals and humans are known to use stars for orientation.
"African ball-rolling dung beetles exploit the Sun, the Moon, and the celestial polarisation pattern to move along straight paths, away from the intense competition at the dung pile."