Engineers have created a robot that mimics a worm's movements - crawling along surfaces by contracting segments of its body.
The technique allows the machine to be made of soft materials so it can squeeze through tight spaces and mould its shape to rough terrain.
It can also absorb heavy blows without sustaining damage.
The Pentagon's Darpa research unit supported the Meshworm project, suggesting a potential military use.
Work on the machine was carried out by researchers at the Massachusetts Institute of Technology and Harvard University in the US, and Seoul National University in South Korea.
Details are published in the journal IEEE/ASE Transactions on Mechatronics.
"[The] soft body, which is essentially compliant, exhibits large strains and enables the robot to traverse small openings and reconstitute shape, and survives from large impact force on falling," the engineers wrote.
They added that using a worm-like motion helped reduce the noise such machines produce, making them suitable "for reconnaissance purposes".
Previous attempts to create such a robot have used gears and air-powered or pneumatic pumps. But these added to the bulk of the machines making them less practical for real-world uses.
The Darpa-supported team instead moved their machine by using an "artificial muscle" made out of nickel and titanium wire designed to stretch and contract with heat.
By wrapping this wire around a mesh-like tube the engineers replicated the circular muscle fibres of an earthworm, creating different segments in the process.
When a current was applied to part of the wire it contracted, squeezing the tube.
The team created algorithm to send a contraction wave across each of the machine's five segments in turn, squeezing the tube and propelling it forward. This mimics the movement of its biological counterpart.
They were able to make the robot move at a rate of about 5mm per second (0.2 inches/sec).
Two additional "muscles" were added to the sides of the machine to pull it left and right, allowing its direction to be controlled.
The researchers said that the soft nature of the robot's body allowed it to be subjected to hammer blows and be trod on without sustaining any damage because its shape changed to help absorb the blows.
"You can throw it, and it won't collapse," said Sangbae Kim, assistant professor in mechanical engineering at MIT.
"Parts in Meshworms are all fibrous and flexible. The muscles are soft and the body is soft... [and] we're starting to show some body-morphing capability."
The Meshworm is just one of several animal-inspired projects being funded by Darpa.
Other examples include a robotic "cheetah" that can run at speeds of 18mph (29km/h), a micro-aircraft equipped with a camera that looks like a hummingbird, and AlphaDog - a four-legged robot designed to carry soldiers' gear.