By J. Michael Kennedy, The New York Times

ALEXANDROUPOLIS, Greece — At the train station here, an unshaven man with a weary look leaned against the brick wall of a building, taking in the morning sun.

He said that his name was Zulifoar Baht; that he was 38, from Pakistan; and that his train for Athens would not arrive until midafternoon. So there was nothing to do but wait, along with a dozen or so other illegal immigrants who had finally made it into Greece from Turkey, crossing one of the most porous borders in Europe.

The 126-mile border between Turkey, which is not in the European Union, and Greece, which is, has become the back door to the European Union, making member countries ever more resentful as a tide of immigrants from the Middle East, South Asia and Africa continues to grow. Frontex, the European Union’s border policing agency, estimated that a vast majority of the crossings in 2011 occurred at the Greece-Turkey border. Last year, Frontex said, more than 55,000 people crossed the border, a 17 percent rise from the year before.

The flow has raised tensions throughout Europe, to the point where the top French official responsible for immigration seriously suggested that a wall be built along the entire border. In Greece, one person in 20 is estimated to be here illegally, at a time when the country is sinking in debt, the far right is making political gains and instances of knife-wielding vigilantes taking out their frustrations on immigrants are becoming increasingly common.

Zarif Bakhtyri, 28, a wiry, streetwise playwright and aspiring film director, said he fled Afghanistan in 2006 after rankling the authorities by writing and directing a play that criticized polygamy. Mr. Bakhtyri’s story is a familiar one — making it to Greece, where he was jailed and then released, then moving along a route that led him to Italy, Norway, Sweden, and back to Greece in 2010 because it was his point of entry.

He, like many others, has been trapped in Greece’s backlogged refugee system, the result, in part, of a longtime European Union rule that stipulated an asylum petition must originate in the first country the immigrant entered. That changed in January 2011, when the European Court of Human Rights ruled that sending asylum seekers back to Greece could infringe on their fundamental rights because the Greek system had become so saturated and living conditions were so poor.

The increase in illegal immigrants in Greece has created support for the extreme-right Golden Dawn party, which has vowed to rid Greece of foreigners who enter the country illegally. Even the country’s mainstream parties have taken a harder line, though the Greek government is widely derided as inept in its efforts to police the border.

Athens is building a $7.3 million fence on the Turkish border to close off the short land crossing between the two countries, but few expect it to stem the flow. In rejecting a request from Greece to help pay for the fence, the European Commission described it as “pointless.”

The last hurdle to Greece is the Evros River Valley, beginning in the north at the Turkish city of Edirne, once the capital of the Ottoman Empire. To the south, on the Greek side, farms sometimes abut barbed-wire fencing, with signs warning of minefields along the dirt roads adjacent to cornfields. Villagers along the border talk of immigrants emerging from the river, wet and cold, as they begin their trek toward Athens.

But the last staging area for most immigrants is really Istanbul, the teeming Turkish city that is a magnet for those who have often walked for months through the wilds of Afghanistan, Pakistan and Iran.

Turkey has come under criticism because of its liberal visa requirements, which make it easy for immigrants to legally enter the country and then move on. Citizens of Kazakhstan, Kyrgyzstan, Syria and Iran, among many other nations, do not need a visa to enter the country.

Once in Turkey, they share crowded apartments and try to find work and save enough to pay smugglers for false papers and passage across the border.

In the cluttered cellar of a dingy Istanbul garment factory, Mustafa Mirzaie, 18, worked with his friend Hussein Rezaie to repair a sink. Both are from Afghanistan, a major source of refugees trying to make their way to Europe. Last winter, they walked for 24 hours over the frigid mountains of Iran into eastern Turkey. Now they do odd jobs to sustain themselves until moving on.

“It’s a difficult way, but it’s the only choice we have,” Mr. Mirzaie said. “I’ll work here and find a smuggler. We have no choice.”

Immigrants in Istanbul often find themselves stuck on a financial treadmill, barely able to meet their basic living expenses. One 17-year-old Afghan named Shamsollah lives and works in a basement sweatshop. He says he will need about $5,000 for the next stage of the journey, though he makes only about $250 a month — just enough to cover expenses.

“Istanbul is very big and very expensive,” Shamsollah said. “I have $1,500 now. But that is not enough for me. I don’t want to stay in Greece without money. There is no work in Greece.”

Sitting at an outdoor cafe recently in one of Istanbul’s poor neighborhoods, a smuggler named Mustafa talked about how he operated his business.

He takes 16 people at a time by van from Istanbul to the border, where his customers walk for an hour to the Evros River and then float across on rubber rafts. He charges $1,000 a person for the three-hour journey. He said he tells his clients not to fear being caught on the Greek side of the border.

“I say to my passengers don’t worry because they don’t want to deport them,” he said. “They just want to register you and take money from the United Nations.”

Sometimes, though, the journey is just too hard. There is a small but growing number of people who have made it to Greece, but returned to Turkey.

Earlier this year, on a windy day in Istanbul, Mustafa and Ali, two 17-year-old Afghan refugees, stood shivering in a park on the Marmara Sea. They had made it to Alexandroupolis but had run out of money. So they returned to Istanbul.

Their only possessions were the shoes, pants and T-shirts they wore. They had waited for hours for an Istanbul contact, but he had not shown up. Without papers, they were afraid even to leave the park and look for help.

And so they sat there, looking out on the sea, wondering what they would do next.

Rachel Donadio contributed reporting from Athens.