The move paves the way for casino resort developments that also include hotels and shopping centres.
International gaming firms including Wynn Resorts, MGM Resorts and Caesars have expressed an interest in running businesses in Japan.
Casino operators are keen to find new markets, especially those in close proximity to China.
Politicians in Japan's lower house approved the bill in the early hours of Thursday. It had already been passed in the upper house.
The move was backed by Prime Minister Shinzo Abe, who believes the changes will stimulate tourism and help the country's flagging economy.
But with legislation still needed on how to regulate the sector, casinos are not expected to open for at least another six years.
An estimate by Daiwa Research Institute suggests that just three casinos in Japan could earn annual profits of $10bn.
But it added that Japan would also have to differentiate itself to attract gamblers in Asia who already can choose to visit casinos in Singapore, Macau, the Philippines, and South Korea.
Politicians have clashed over plans to legalise casinos in Japan for the past 15 years, with strong opposition based largely around fears of gambling addiction and other social fall-out such as organised crime.
And pro-casino campaigners have had to try and allay fears about the negative impact of casinos, promising measures to combat addiction and money laundering.
An opinion poll by public broadcaster NHK found 44% of those questioned opposed the plans, with just 12% supporting it and 34% of respondents undecided.
Casinos are currently illegal in Japan, though gambling on horse, boat and bicycle races is allowed through government-backed bookmakers.
The most common form of gambling in Japan is Pachinko, the country's take on pinball. Played in parlours across Japanese towns and cities, the game is tolerated despite its legal status remaining vague.
Japan's parliament has passed a long-awaited law to legalise casinos.