From the Super Mario Wiki
Ads keep the MarioWiki independent and free :)
Invincible Mario is a form that makes its debut in Super Mario Bros. Mario can assume the form after using a Super Star, which made its debut in the same game; while in this state, he is resistant to any enemy, and can defeat most of them by simply touching them. However, the state only lasts a few seconds, and Mario can still lose lives from falling into a pit, touching lava or poison water, being crushed, touching Volcanic Smog, getting crushed between a wall and a Boohemoth, or running out of time. Since this is not a "true" transformation, Mario can become invincible and retain his current form (for example, if Fire Mario gets a Super Star, he becomes invincible, but retains his Fire form).
In most games, when Mario is damaged, he will be invulnerable for a few seconds as well (though he cannot defeat enemies).
Invincibility is depicted by a flashing, color-changing character. Since Super Mario Bros. 3, Mario flips when he jumps in this form, in a similar fashion to Samus Aran, who only appears alongside Mario in the Super Smash Bros. series.
In Super Mario Bros. 2, Super Stars and thus, invincibility, are gained by grabbing five Cherries. Because enemies respawn off-screen and hearts spawn for every eight foes defeated, this form is mainly used to recover health.
As of Super Mario Bros. 3, there are some ? Blocks that normally contain coins, but will contain Super Stars if Mario or Luigi is invincible when they strike the block. This allows the player to string together a long period of invincibility, and thus gain even more points.
Starting in Super Mario World, Invincible Mario could get extra lives by defeating eight (five in Super Mario Land 2: 6 Golden Coins and Super Mario 3D Land) or more enemies while invincible, and will keep getting lives for each additional enemy (every eighth enemy in Super Mario 3D World) defeated until the Super Star wears off completely, and the player becomes vulnerable again. This property was also included in the Game Boy Advance remakes of Super Mario Bros. 2 and Super Mario Bros. 3, which originally did not have it.
In the Mario Kart series, every driver can become invincible by touching and/or using a Super Star, allowing them to drive faster and make other drivers spin-out or tumble by touching them, unless both drivers are invincible, in which they bump each other normally. The Super Thwomps of the original Rainbow Road are also invincible, causing the same effects to any driver that runs into them.
In The Super Mario Bros. Super Show!, neither Invincible Mario or Luigi ever made an appearance, as a Starman would not turn Mario or Luigi invincible, but instead served as an alternative to the Fire Flower for becoming "Super Mario" or "Super Luigi". In The Adventures of Super Mario Bros. 3 and Super Mario World, Starmen functioned as they normally did in the games, granting them their Invincible forms for a limited time.
Additionally, in the Donkey Kong Country series, the Kongs can become invincible by breaking through an Invincibility Barrel. While invincible, they gain the same effects as a Super Star, such as flashing and defeating enemies without performing a specific move. They also still lose a life if they fall in a pit, even when invincible.
In Mario & Luigi: Bowser's Inside Story, Bowser Memory M uses a Super Star to become invincible and attack the Mario Bros., complete with the theme music and the effect of knocking a hit bro off-screen for the move's duration.
In Yoshi's Woolly World, once Yoshi is granted an Invincibility Egg due to being defeated five times and Yoshi touches it, he will glow orange and be immune to damage from enemies and their attacks. However, he can still be pushed by enemies, instantly defeated by spike pits, bottomless pits, can still be crushed, and still can be scalded by lava. Yoshi cannot instantly defeat enemies by touching them.
Names in other languages