It is considered certain that at least among Samurai warriors, left-side passage had been observed many years ago.

Left-side passage not only allowed right-handed Samurai to draw their swords more easily in case of emergency but also prevented two mutually approaching samurai from getting into a duel when the sheaths of their swords hit each other, which happened quite often in days of yore. Samurai ruled the Japanese society during Edo period (1603-1867). And left-side passage suited their peacetime lifestyle. So left-side passage could be considerably prevalent in Japan back then.

But this does not necessarily follow that non-Samurai people--farmers, craftsmen, merchants--strictly kept left-hand traffic. These people did not carry swords in the first place. Furthermore, it had been a traditional custom in Japan to put up nameplates on the right posts of the gates when you see houses from the outside.
It had also been a traditional custom here to show names of the bridges in Chinese characters (therefore more politely) on the right posts of the bridges when one faced the bridge while those in Japanese syllabics on the left posts.

Two Europeans ( Engelbert Kaempfer and Carl Peter Thunberg) wrote that people were keeping to the left. But it is possible that non-Samurai people were keeping to the right only when they came up against top brasses like Samurai or foreigners. People in Japan could be moving every which way with the exception of Samurai warriors.

In early 18th century, Engelbert Kaempfer (1651-1716), a German naturalist, wrote in his book called "Edo travel account" that left-side passage was stipulated on Japanese highways (Edo is an old name of Tokyo). He stayed in Japan from 1690 to 1692. He wrote "according to the Japanese custom, people who travel to the capital (including himself) have to keep to the left while people who travel from the capital have to keep to the right. This custom took root and became a rule."

In late 18th century, Carl Peter Thunberg (1743-1822), a Swedish botanist, wrote in his book called "Edo travel accompaniment" that left-side passage was observed by all travellers on Japanese highways and added that a clear-cut traffic rule like this had to be set up in Europe as well. He stayed in Japan from 1775 to 1776.

The most decisive factor in the Japanese history that brought about our present left-side driving came in 1868, when our isolationist feudalism was replaced by Western-style democracy (though it was nominal democracy back then). We realised our backwardness and started absorbing Western civilization like fury.

The railway system was one of the most prominent intake from the West at that time. Three countries approached the then Japanese government in terms of the introduction of the railway system: USA, France and UK. At first France and USA prevailed but in the end UK swayed away Japanese government decision by offering a state-run railway plan which best agreed with Japanese officials' idea. In 1872 the first Japanese railway ran with English technical aid. It was, of course, left-side driving (at stations, I mean, the main line was single-track). This is proven by the photos or paintings drawn those days. A massive network of railways had been built ever since, all of which were left-side running. If American or French railway had been built, instead of English, we might have found right-side traffic in today's Japan.

But the left-hand traffic discussed above is still limited to railways. The biggest avenue that effectively promoted left-side traffic on the Japanese road system is considered to be horse railways, and its successor: electric tram cars. As you may have known, horse railways are stage coaches that ran on railways on streets. They first ran in Japan in 1882 with double-track railway. Since they were a railway after a fashion, they were left-side passage in Japan. They developed in a big way as street transportation, especially in major cities. In 1903 horse railways were started to be replaced by electric tram cars. But since they used the same railways as the horse railways, left-side driving continued. And they are considered to encourage other transportation to keep to the left down the road.

In the 19th century the Japanese laws and orders on the passage of roads seemed still confused. Stage Coach Order issued by the Tokyo Metropolitan Police in 1881 said mutually approaching horses and vehicles had to avoid each other by shifting to the left. But an order issued by the same Tokyo police in 1885 stated that general horses and vehicles had to avoid to the left but when they met army troops they had to avoid to the right.

Japanese armies were keeping right on roads, as their ideas did, until 1924. Osaka government, which is the second largest city in Japan, issued an order in 1872 that horses and vehicles had to keep to the right of roads. It was not until early 20th century that left-side passage effectively took root among ordinary Japanese people.

In 1900 Tokyoites arguably saw the first automobile run in Japan.
An order issued in 1902 by the Tokyo police said for the first time that pedestrians had to keep to the left side of roads. 1907 saw the first Japanese killed by an automobile accident. A newspaper article dated January 1st of 1906 reads "we have recently seen the development of such transportation as trains, cars and bicycles. But it does not necessary accompany a corresponding street condition and we have seen increased traffic accidents.
In light of the swollen danger on roads, Tokyo Metropolitan Police are going to enforce that same old left-side traffic on pedestrians in addition to tighter regulation on trains."

In a book called 'Origin of Meiji (a Japanese era referring to 1868 to 1912) things,' it was 1924 when left-side driving was clearly written in a law.