Immigration has long been taboo in a country where many prize ethnic homogeneity, but the shrinking, ageing population has increased pressure to relax strict controls on foreign workers.
The legislation, which was approved by parliament's upper house in the early hours after delaying tactics by opposition parties, will take effect from April. It creates two new categories of visas for blue-collar workers in sectors facing a labour crunch.
One category is for workers who can stay for up to five years but cannot bring family members. The other is for more skilled foreigners who can bring relatives and might eventually be eligible for residency.
Details including how many foreign workers will be let in, what sectors are covered and what skills are needed are not spelled out in the law, one reason opposition lawmakers say more time should have been spent drafting the legislation.
The government has said that up to 345,150 blue-collar workers will be allowed in over five years. Initially, a figure of 500,000 was considered.
Prime Minister Shinzo Abe is eager to respond to demands from businesses facing the tightest labour market in four decades.
But he is also wary of angering conservatives in his party who fear more foreigners would mean a rise in crime and cultural clashes.
He has therefore insisted the new steps do not add up to an "immigration policy", stressing instead the need to fill labour- market gaps.
But critics say the government should accept the need for long-term foreign residents, not only to fill jobs but to pay taxes and spend money, and should make better plans to integrate them.
"For the national government, foreign residents are forgotten people ... and those who stay are the exception," said Toshihiro Menju, managing director of the Japan Center for International Exchange think-tank.
The changes have fanned concern that the defects of a "technical trainees" programme, introduced in the 1990s, will be perpetuated. Critics see that programme as an exploitative backdoor to unskilled foreign labour and want it abolished.
"Because the trainee programme got a bad image, they are just re-labelling it," said Yohei Moriwake, head of a non-profit organisation in Akitakata, a rural city in southwest Japan that wants to attract more foreigners to stem its population decline.
Japan has about 1.28 million foreign workers - more than double the figure a decade ago and about 2 percent of the workforce. About 260,000 are trainees from countries such as Vietnam and China who can stay three to five years.
Japanese businesses are keen - a Reuters survey showed three-quarters welcomed the planned changes - but voters are divided over the new legislation.
A November survey by NHK public TV showed 27 percent approved, 30 percent disapproved and 36 percent were undecided.
A majority - 62 percent - saw no need to rush the revision through this session of parliament, which ends on Monday. (Reporting by Linda Sieg Editing by Robert Birsel and Daniel Wallis)
(This story has not been edited by Devdiscourse staff and is auto-generated from a syndicated feed.)