Instructions
Perfect the Z-Stomp move, also known sometimes as the Butt Stomp. Run around in an area of the game, jump using the green "A" button, then press the "Z" button while in the air. This will cause Mario to stop mid-air, do a front flip, then use his butt to stomp the ground right below him. This move is required to access Chain Chomp's star.
Enter the Bob-omb Battlefield world. To access it, enter the main castle and enter the door farthest to the left. It is the only door with a star on it that does not have a number and is the first accessible world in the game. Jump into the painting of the black Bob-ombs after going through the door to enter the world.
Follow the brown path on the ground until you cross a bridge. Hook to the left, continuing to follow the path, until you reach the giant Chain Chomp on your right. Behind him will be a gate with a star behind it. The Chain Chomp is attached to a stake in the ground with a red coin spinning atop it.
Move close to the Chain Chomp until it lunges at you, then dodge out of the way, and immediately run for the stake in the ground. Perform a Z-Stomp over the stake, which should press it into the ground a little bit, then move out of the way of the Chain Chomp before it bites you.
Repeat Step 4 three times until the stake is fully in the ground. At this point, the Chain Chomp, now freed, will jump away into the sunset, and the gate in front of the star will open up, allowing you to access the star.