Before the village system was established with the founding of Konohagakure by the Senju and Uchiha, the Era of the Warring States (戦国時代, Sengoku Jidai) was an extremely lengthy and bloody period in history where hundreds of individual shinobi clans fought in constant, bitter warfare.
During this era, conflicts perpetually arose between the various nations as each crusaded for more rights and land. In order to wage these wars, each individual shinobi clan rented its military might to the highest bidder. Due to the unrelenting violence, the average life-span for a shinobi was a mere 30 years, though the single biggest reason for the continuing fall in life expectancy was the slaughter of countless conscripted children. With the continued loss of their kin, a never ending cycle of death and revenge was born, which saw shinobi having to even conceal their surnames for fear of retaliation.
Amongst the warring clans, only two came to be feared as the strongest: the Senju clan and the Uchiha clan, who developed a deep enmity as they were often hired to oppose one another due to their rivaling strength. Eventually, both Hashirama Senju and Madara Uchiha grew to become the respective leaders of these rival clans, but despite their childhood friendship, the two were inevitably pitted against one another. During this time, Madara and his brother discovered the secret of the Sharingan; becoming the first to awaken the Mangekyō Sharingan. Though with the constant battles, Madara's vision degraded further and further until he decided to take his brother's eyes, gaining an "Eternal" Mangekyō Sharingan with which to keep fighting.
However, after decades of fighting, most of the clans under the Uchiha and Senju banners formed the first lasting truce after growing weary of the continued bloodshed. The only person who opposed this peace was Madara, who argued for the Uchiha clan to continue the fighting, but was ultimately persuaded to join in a permanent alliance with the Senju clan. Soon after, a pact was formed with the Land of Fire and thus, Konohagakure was formed. This set a precedence which others soon followed, creating the Five Great Shinobi Countries, as well as some smaller, outlying villages and settlements.
The Sengoku Period (戦国時代, Sengoku Jidai) or Warring States Period, was a time when Japan was in civil war and the demand of ninja was high. This moment in history was the time of many of famous ninja, including Sasuke Sarutobi. But after the war resolved, their services were cut in a united Japan, ninja began to fade into history.