Soul-searching debates across the continent in recent months have brought to the surface the immigrants' dilemma: being caught in a no man's land between the ghettos they now call home and the countries of their birth thousands of miles, and several cultures, away.

Uncovered, too, has been an embarrassingly deep-rooted and growing hostility toward foreigners reflected in man-in-the-street remarks (''They're taking our jobs'') and comments by top-ranking government officials and academicians. Even official policy is being reshaped to take account of the situation.

In West Germany, for example, 4.65 million foreigners (about a third of them Turkish) account for 7.5 percent of the population. Interior Minister Gerhart Baum, pointing to the country's 2 million jobless, said recently, ''We must make it clear to them [the immigrant workers] that we have reached the limits of our capacity.''

In fact, Bonn has already imposed strict immigration curbs on wives and children of foreign workers living in the country.

The immediate response to the immigrant problem -- as unemployment has risen and the recession deepened -- has been to encourage foreign workers (mainly Turks and North Africans) to repatriate, rather than to smooth their integration into society.

The French government took the lead in the field several years ago when it offered about $2,000 to each immigrant who would leave the country. Only 57,000 (out of about 4 million immigrant workers), however, took advantage of the offer , so President Francois Mitterrand called a halt to the plan last year. Some immigrants, it was discovered, were leaving France five or six times.

Nevertheless, several other governments -- notably in West Germany, Belgium, and Italy -- have recently taken up the idea as perhaps the only morally acceptable means of reducing their immigrant populations.

''We can't just put millions of foreigners on boats tomorrow,'' one Belgian official said.

A West German newspaper described the situation, ''In the late 1960s, when German industry was starved for labor, the one-millionth Turkish worker was given a television set.'' Today, the newspaper said, ''the two-millionth will be given a ticket home.''

In the early 1960s, when the jobless rate was low, the immigrant workers arriving in Europe were given a pat on the back. They were gladly given the menial tasks the Europeans shunned.

But as unemployment tops 10 percent in many West European countries, resentment toward immigrant workers has reached the point where many governments are under pressure to export the unemployment problem. In at least four countries -- Belgium, France, West Germany, and Luxembourg -- foreigners make up more than 10 percent of the labor force.

Some 200,000 foreign workers were booted out of Switzerland in the mid-1970s as the country's construction industry neared collapse.

It is considered unlikely other European countries will exercise that option -- mainly because millions would have to be exported. But opinion polls indicate that more and more people would like the immigrant workers out.

In West Germany, for instance, two-thirds of those polled want immigrant workers to return home, compared with only one-third three years ago.

Even Sweden -- long known for its exemplary aliens policy -- has been forced by public opinion to slow the flow of immigrant workers because of the weakening economy.

Faced with this xenophobia and the prospect of ever-rising unemployment, immigrant workers might be expected to be flee Western Europe as quickly as they came.

But they are not. Among the principal reasons is Western Europe's cradle-to-grave welfare system (which some officials say could collapse under the weight of immigrant workers).

''I like it here very much, mainly because of the social benefits,'' says Mahmout, a young Turkish worker who has lived in Belgium for four years. ''If I can't find work,'' he shouts above the juke-box music of a small cafe frequented by foreign workers, ''I still get paid. It's not like that in Istanbul.''

Older immigrant workers, while never feeling entirely at home in a foreign country, have developed certain ties here, and when they have work, the pay is often better than it would be back home. Their children also receive better education and religious training.

In Belgium, for instance, where Islam is the second largest religion in a predominantly Roman Catholic country, numerous storefront mosques -- as well as close imitations of large mosques in Muslim countries -- provide children with an education intimately linked to their way of life.

Their future, however, remains precarious.

The Geneva-based International Labor Organization recently called the 4.1 million children of immigrant workers in West Germany, France, Sweden, Switzerland, and the Netherlands ''a sociological timebomb.''

The organization predicted that if present trends continue (with birthrates among immigrant workers far surpassing those of native Europeans), one-third of the children in Europe will be ''foreign'' by the end of the century. In some countries -- such as Sweden -- the figure could be one-half.

''Not long ago,'' said a sociology professor, summing up a recent conference on racism in Belgium, ''we weren't even talking about the problem. Now, as immigrants are being increasingly stigmatized by Belgians and other Europeans as the principal cause of our economic woes, we're beginning to face up to it, to discuss it openly. That's healthy. Finding a solution will take time. But we must.''