Literally, ninja means "in stealth". The Ninja were a class of fighters/spies that mainly existed during the 6th to 17th century in Japan. A lot of myth and bullshit ideas exist about the ninja, but to say that they were mere spies, or a pure fiction would be a critical error.

Originally, due to Japan's strict caste system, samurai, the bushi class of warrior-gentleman were (and still are) honour-bound by the strict code of bushido, which subsequently meant they could not perform dishonourable acts such as espionage.

Because they were so limited, a new warrior class came into prominence - the ninja. These people came from the hinin - literally "not human" - class, the lowest in the Japanese caste system. They were merciless warriors, often but not necessarily mercenaries, who committed acts of espionage - among them spying, sabotage, assasination and terrorism. Although not honour-bound - far from it, ninja were considered totally ruthless - they also followed their own code, which included the samurai concept of fighting to the death. Ninja were as tightly bound to their code as the samurai were to theirs. Being a ninja encompassed one's life, not just the profession.

Ninjas practised ninjutsu - not just an art of fighting, but of espionage. As spies, they employed a wide variety of weapons, but they are probably most well-known for their shaken (or ninja stars - a common labels these as shuriken, but that term refers to either their entire collection of sharp pointy death devices, or the actual art of throwing said ouchies). They were also skilled in chemistry - the use of poisons and other drugs was very commonplace.

Ninjas were organised into ryu - schools, much like the other martial arts. Each school was the latterday equivalent of a clan to the individual ninja. Often each ryu would specialise in a different forms of their profession - for instance different styles of combat, espionage, assasination, lore. It was virtually impossible to infiltrate a ninja ryu - you were either born into it, or not in it.

They were first employed by Prince Regent Shotoku in the 6th century, and their success rose dramatically during the Heian and Kamakura periods in Japanese history, and the last major use of them was in the Shimibara war in 1637 when they quelled a Christian uprising. (I believe the bad anime Ninja Resurrection was based on this). Today they are believed to have faded from existence, but - not being melodramatic - you never know

However as always a lot of Western media - movies and novels alike - have totally fucked up the concept of the ninja - along with bujutsu, bushido, the samurai and just about anything else they can sensationalize. That said, skilled authors who know what they're talking about do exist. One such is Eric Lustbader, who's book The Ninja is where much of this information comes from.

Today, especially in geek culture, 'ninja' refers to someone who is especially adept with a particular craft or profession - for instance script ninjas, unix ninjas, quake ninjas, noding for ninjas and ninja kick-ass skills. Generally such 'ninja' practise their skills with a lot of flair and style.