The Samurai or Bushi - were the Warrior Knights of Pre-modern Japan.

They later made up the ruling military class - Samurai employed a range of weapons such as bows and arrows, pole-arms such as spears and naginata eventually firearms - matchlock guns arrived in 1543, but their main Personal weapon and symbol was the Sword.

In the 12th Century, two military clans named the Minamoto and Taira had become very powerful.

These clans controlled much of Japan. The Minamoto and Taira clans also fought wars against

each other. 

In 1192 the Minamoto Yoritomo was very successful.

Yoritomo became the first Shogun, which was the highest military position in Japan.

He became the ruler of all of Japan and started a new government in Kamakura.

This government made the Samurai the ruling Class of Japanese society.

Toyotomi Hideyoshi (1536 or 1537-1598) won many wars against other clans. When he attempted to unify Japan as one country, Hideyoshi developed a almost iron-clad social caste system, that would prevent any one to become Samurai that was not already with his famous sword hunt.

Between the wars many Samurai had always worked on farms.

Hideyoshi said that all Samurai must now make an important choice: they must decide to live

on farms or to live in castle towns with other warriors. Hideyoshi also made a law about swords. 

"He said that the Samurai were the only people who could have swords".

Some Samurai did not have Daimyo Lords.

These Samurai were called "Ronin" some of these Ronin caused some problems

for Japan in the Early Edo period

In the Edo Period (1603-1867), the Samurai were the most important social caste.

After the Samurai were the Farmers, Artisans and Merchants. All Samurai had to live in castle towns.

The Samurai Lords paid them with rice known as koku. 

In 1615, Tokugawa won a very important battle at Sekigahara 1600's, then again in 1615 when he defeated Toyotomi heir of Osaka Castle. The Tokugawa Clan only had only minor rivals and skirmishes such as Shimabara Christian Rebellion.

This Caste system of Government was later completed & refined by Tokugawa Ieyasu

and the Shogunate line of Tokugawa Rulers that followed after him. 

Japan became very peaceful for about 250 years. During this time military skills became less important. Most Samurai became bureaucrats, teachers or artists.

Until foreign influences; such as the Satsuma / Namamugi Incident followed on by British naval bombings of Kagoshima coastline in 1863. The United States of America trade demands lead by Commodore Matthew C Perry, place significant pressure on ancient Shogunate system which had closed its doors all trade to the outside world with exception of the Dutch, which had a small port for trade in Nagasaki.  

It was excessive demands from outside Nations which one could say divided and sparked conflict across Japan such as Boshin wars which lead the Nation of Japan into Imperialism via the Meiji Restoration, put simply the Shogunate was no more and now Japan was under the direct control of the Emperor Meiji this occurred in 1868. 

This was the end of the Samurai as an Elite ruling class

Images below:

A famous real life Kumamoto Samurai named "Gensai Kawakami" middle photo featured below this paragraph.

Otherwise, more commonly known as the Character Rurouni Kenshin - Hitokiri Battousai

in the popular & mostly fictional Samurai X, who real life events inspired manga series.