Home for Tanaka is Manga Square, a 24-hour internet cafe and comic lounge in the Ikebukuro neighbourhood of Tokyo. It is one of thousands of cafes across Japan that have become de facto shelters for people who can't afford to rent a place of their own: the unemployed and others, such as Tanaka, who depend on daily contracts in construction work to survive. According to a recent government survey of the people the media has dubbed "net cafe refugees", 5,400 people spend at least half the week living in cafes such as Manga Square, though most have little or no interest in the internet. Instead, they are attracted by the low cost of a night's accommodation, an expanding array of services and the sympathetic attitude of cafe owners.

Manga Square, which occupies two floors of a run-down building near Ikebukuro station, looks more like a hostel than a cafe. The exodus from the street begins after 10pm as dozens of mostly middle-aged men, many weighed down with bulging rucksacks, file in and make their way to the free soft drinks or order cheap, grease-laden meals. Today's special is a plate heaving with chips, sausages, a burger, fried fish, rice and shredded cabbage - all for 830 yen (£3.60). There is no small talk as, drinks in hand, they head for their cubicle, making sure to lock the door behind them. A fog of cigarette smoke rises to the ceiling and the silence is broken only by the click-click of computer keyboards and staff delivering food orders.

Tanaka has been dividing his time between internet cafes, capsule hotels and all-night saunas for the past three years since fleeing his home in Saitama prefecture, north of Tokyo, after falling behind on his rent. "I know it's cramped here, but there is no way I could afford the deposit and rent on an apartment, even a one-room place," he says as he devours a Slush Puppie with a plastic spoon. "All the drinks are free, I can use the PC for as long as I like, and there's even a shower upstairs."

For all this he pays about 1,000 yen (£4.30) a night. On days when there is no room at the cafe, or when he craves a little more comfort, he pays a little more and stays at a capsule hotel - a bed and a TV in a room only slightly bigger than a coffin, with communal showers. What little cash he saves goes on occasional trips to a nearby "soapland" - sex shops where the female staff administer soapy "massages" - for 15,000 yen (£65) a time. "Even though I'm penniless, I am still a single, ordinary guy, and I like to play a bit from time to time," he says.

Tonight, though, Tanaka will be asleep by 11pm. He will be up again at 5am and, after a breakfast of two rice balls, a fried egg and a bowl of miso soup, out of the door in search of another day's casual labour. He keeps his expenditure to about 3,000 yen (£13) a day, does not receive bonuses, and has no health insurance or pension. At a town hall somewhere in Saitama prefecture there is a residence permit with his name on it. But as far as the authorities are concerned, Tanaka might as well not exist.

He is one of a growing number of Japanese left behind by their country's recent economic revival. The government survey found that about half of the net cafe refugees worked in low-paid temporary jobs, while 2,200 had no job at all. Those in work earned just over 100,000 yen (£430) a month - about the same as the minimum wage for a 40-hour week, but nowhere near enough to afford a tiny apartment of their own. About a quarter were in their 20s but it is not unusual to find men - four out of five net cafe refugees are male - in their 50s and 60s sleeping in places such as Manga Square.

They are members of a new underclass that has emerged from the economic and social reforms that began six years ago under the then prime minister, Junichiro Koizumi. His enthusiasm for the free market and cuts in public expenditure have widened the income gap, with young people the biggest losers. Last year the Organisation for Economic Cooperation and Development was moved to voice concern about Japan's abandonment of its egalitarian wage policy. Between 2001, when Koizumi came to power, and 2005, the number of people earning less than a million yen (£4,300) a year rose by 16% to 3.6 million, according to the tax agency. The number of households receiving welfare has soared by 66% to one million in the past decade and youth unemployment, at 8.8%, is twice the national average.

Anti-poverty campaigners say the government figures vastly underestimate the true number of net cafe refugees. The recent survey included only people staying in net cafes at least three times a week, and ignored those who spend other nights in saunas, capsule hotels or fast-food restaurants, or who bed down on the street in big cities such as Tokyo and Osaka.

"Ten years ago I would never have believed we'd see people living in net cafes," says Makoto Yuasa of the Moyai Independent Life Support Centre, a non-profit organisation that offers advice on housing and job-seeking to the unemployed and poorly paid. "But in today's Japan it is a fact of life. These people are basically homeless, even though they are not sleeping rough. If you surveyed everyone with no permanent home, the figure would run into the tens of thousands."

Largely ignored by the government until recently, members of this new underclass have had to depend on volunteers for help. Yuasa, who formed Moyai in 2001 after receiving emails from desperate net cafe dwellers, says: "Most of them are denied welfare. They are comparatively young and fit, and are told to go away and find a job."

The labour ministry will start offering employment advice to net cafe refugees next year, but campaigners say the priority should be finding them accommodation, starting with an increase in the number of public shelters to reflect the size of the homeless population, which is believed to be between 25,000 and 45,000.

The young account for many of those who have slipped through the net. While the job situation has improved for university graduates, young people with few or no skills or qualifications - the so-called Neet generation (not in employment, education or training) - make ends meet through badly paid part-time jobs in shops and bars.

The number of 25-to-34-year-olds in nonregular employment stands at around 26%, and is spreading beyond the service sector to include manufacturing, experts say. "Poverty is more widespread among young people than expected. The existence of [net cafe refugees] proves just how difficult working and living is for them," says the Young Contingent Workers' Union, which represents part-time and casual workers.

More than a decade of economic stagnation and corporate restructuring has ripped apart the guarantees, made to their parents, of lifelong employment and seniority-based pay. "The problem is that young people today have nothing to focus their energy on," says Yukie Hori, a researcher at the Japan Institute for Labour Policy and Training. "Their parents' generation had the student movement and the postwar economic boom, but they don't even have the stability that comes with a proper job. It is harder than ever to find salaried work, so they can't relax and enjoy life knowing that at least their job and pension are secure."

Official figures show that 640,000 Japanese under 35 are classed as Neets. The Dai-ichi Life Research Institute, a private thinktank, estimates that if current trends persist, the Neet population will rise to more than a million over the next 10 years. They include Hiroshi Miyamoto, one of the first people to arrive at Mankitu, an internet cafe in Tokyo's sprawling Shinjuku district, late on a recent Monday evening. The air here reeks of stale smoke, sweat and fried food, but for 380 yen (£1.60) an hour, Miyamoto, 33, is given a private cubicle furnished with a long couch, a PC and a desk lamp. There is a shower room on the premises, and the reception sells soap, shampoo and hand towels for a fraction of the price charged in the high street.

Miyamoto has been unable to find permanent work since he left his home town on Hokkaido, Japan's northern island, three years ago after losing his job as a truck driver. Limited to low-paying casual work, he hasn't been able to hold down any job for more than a few months.

"I get bored very quickly and fed up with the pay," he says. To break the monotony, he divides his week between three or four places in Shinjuku, trying, and often failing, to keep himself to a budget of about 3,000 yen a day. "At first I was really homesick but I'm getting used to it. I even made a friend the other day and we went out for a beer," he says.

But most of the time, Miyamoto's is a solitary existence. He spends any leftover cash gambling on horses or playing pachinko, a type of prize pinball. "I'll be out of the door again at 7am tomorrow looking for work. I know my money won't last for ever. All I can do is keep trying."

Other net cafe dwellers are not so much searching as running away. "I'm a wanted man," says Katsuo Watanabe as he lights a Marlboro on the stairwell at an internet cafe in Ikebukuro. A self-confessed gambler and heavy drinker, Watanabe's life began to fall apart three years ago when work as a day labourer in Tokyo became more irregular and he fell behind on his rent and defaulted on his repayments to loan sharks. The 57-year-old, who, despite his lifestyle, looks 15 years younger, walked out on his wife and daughter and embarked on a life of hard graft on assorted building sites, and evenings chain-smoking and reading comics alone in his cubicle. Still, he tries to stay optimistic about his predicament as he dismisses the regimentation of life "on the outside".

"Japanese society demands that you belong to one group or another and obey the rules," he says. "Here you can be yourself."

Tanaka is similarly sanguine. "I don't think of staying here as a good or bad thing. It's just the way Japan is at the moment. The staff here treat us like ordinary customers. They know why we're here but they don't object at all."

An estimated 75% of Japan's 3,200 all-night internet cafes cater to regular overnight guests, who in some cases have become their main source of income. One chain allows guests to come and go once they have paid their admission fee and provides small rooms with tatami-mat floors to sleep on for just 100 yen (40p) an hour.

Image-conscious cafe owners have also criticised the popular description of their customers as refugees. "There are certainly some [customers] who have a hard time finding regular work, but ... these people are very important customers," says the Japan Complex Cafe Association, which represents about 1,300 internet cafes. "Some reports give the impression that groups of vagrants and homeless people gather at internet cafes every night. The media should be aware that such reports can scare off customers."

Despite reports that the cafes have become hotbeds of crime and prostitution, Tanaka says he has not had a single unpleasant experience in his time living in a cubicle. "Everyone pays their way and I haven't seen so much as an argument, let alone a fight. The worst thing about sleeping here is being kept awake at night by my neighbours' snoring."

Living in a net cafe can be hazardous, though. Many long-term residents suffer from back pain and haemorrhoids, and are susceptible to colds and other viruses. Depression is common, particularly among women, who, according to official figures, make up about 20% of the net cafe population.

Yet an estimated 70% do not have health insurance. "When they fall ill, the most they can do is buy over-the-counter drugs and hope," says Yuasa. "They can't cool down or warm up because they have no bedclothes, and it takes ages for them to recover from something as innocuous as a cold. For people who rely on casual work to make ends meet, that can be disastrous."

Watanabe, meanwhile, is hoping to earn enough money to take his 27-year-old daughter out for a meal, although it seems she would rather he saved any spare cash, most of which, he admits, goes on drink, cigarettes and gambling. "She worries about my health as well," he says. "But it's impossible for me to leave here at the moment. I've nowhere else to go, and even if I did, once people know I am around, they will start demanding their money back. Having said that, I can't go on living like this for ever. Not at my age".

The dispossessed: Hidden homelessness around the world

You don't have to be sleeping on the streets to be homeless. According to Feantsa, a federation of European homelessness agencies, being forced to live in an institution because you have nowhere to go, having a roof over your head but no security of tenure and living in unsanitary accommodation all effectively mean you don't have a proper home.

In Chile, this means that the 15% of the urban population forced by poverty to share a house with two or three other families are effectively homeless. So, too are around 10% of Caribbeans in "shift" accommodation; some will occupy a room from 8pm to 6am before it is taken over by the next shift.

In the UK, Shelter estimates that thousands of eastern Europeans are living in unsatisfactory housing, some in grossly overcrowded properties, others braving the cold in tents. In Spain "pensiones informales", illegal and overcrowded guest-houses, have sprung up to accommodate African immigrants, as have "bossos" that perform the same function in Italy.

In the US, a lack of secure tenure given to people living in some poverty-stricken trailer parks makes them borderline homeless too. If you could be evicted tomorrow, having a roof isn't the same as having a home.

The greatest form of homelessness, however, could be said to be slum dwelling, defined by one or more of the following characteristics: lack of water, lack of sanitation, accommodation made from non-durable structures, overcrowding, and no security of tenure.

According to the United Nations Human Settlements Programme, 31.6% of the world's urban population lives in slums. In Asia-Pacific countries, that figure rises to 43.2%, while in sub-Saharan Africa it reaches a staggering 71.9% (in Sierra Leone it is 96%). Many of these people will work and have a roof over their heads. But they may never achieve their dream of a clean and sanitary home made of durable materials and with the assurance that they won't be evicted at a moment's notice.

Eduardo Moreno, chief of the UN's Global Urban Observatory, says that globalisation and increased migration are forcing more and more people into situations where they could be defined as homeless.

"What we are seeing is the manifestation of a new phenomenon, a kind of hidden homelessness, and it is quite clear that we will see more of it," he says. "In developed countries, the movement of unskilled work to developing countries results in a lack of proper work among people who would once have had jobs. Some take a few hours' work here and there when they can get it, but it doesn't pay enough for them to afford a proper home.

"And in Europe, Canada and Australia we are seeing negative population growth, so there are not so many young people to do the work. That results in immigration and, where governments try to close doors and put up walls to that, you have illegal immigration and all the attendant problems with people finding somewhere to live."

Steve Boggan