ISTANBUL, Turkey — Obaida, a 22-year-old refugee from an area of Syria controlled by Islamic State, said he tried hard to get a passport the legal way. In May, he paid his way to Istanbul from the border town in Turkey where he now lives. He spent five days waiting in line at the Syrian consulate. He was told to return in a year.

That’s too long for the former chemistry student, who supports his family in Syria with cash he earns through odd jobs in Turkey, including work at a nonprofit. He needed a passport — with a valid Turkish entry visa stamp — to apply for a residence permit that would give him opportunities beyond those afforded to anyone who registers as a refugee with the Turkish government.

“I didn’t want to have to ask anyone for help,” said Obaida, who asked that some identifying details not be used because he fears both Turkish authorities and Islamic State. Registering as a refugee would get him a temporary ID card. But it would not allow him independence: the right to work, rent an apartment or open a bank account.

He saw no other option but to seek out a growing network of document forgers who are capitalizing on refugees’ and migrants’ need for civil documents. He says he bought his first fake passport inside Syria for $1,500, but Turkish border agents would not accept it. Recently he bought his second for just $250, complete with his photo.

As the Syrian civil war grinds into its fifth year, refugees are grappling with administrative headaches stemming from missing documentation. At least 4.1 million Syrians have fled the country, according to the United Nations High Commissioner for Refugees, and about 1.9 million are registered in Turkey. Many left without their marriage licenses, birth certificates and ID cards, either because they fled in a rush or feared being identified or arrested at checkpoints.

But going home to retrieve paperwork is often a dangerous or impossible task. And while they can theoretically visit their embassies and consulates for replacements or renewals, many fear getting in touch with a government they may have opposed. This includes human rights advocates and activists who supported the 2011 revolution, in addition to opposition fighters.

A 2013 survey by the Turkish government’s emergency management agency found that fewer than 30 percent of Syrians had entered Turkey — the common starting point for the long journey into Europe — with a valid passport. That number could be even lower now as passports expire with challenges for renewals.

Over the past few years, police across Europe have tried to block tens of thousands of Syrians from crossing their borders. But with many Syrians unable to obtain or renew their passports and identity cards, they cannot seek refuge safely and legally via commercial flights or passenger ships.

Forgeries are sometimes their only hope. Facebook pages geared toward refugees advertise not only passports but birth certificates, marriage licenses, college diplomas, and family books, the official logs of all the members of a family. User comments attest to the documents’ quality or tell potential buyers not to bother.

Reached by phone, one documents forger in Turkey said he sold “genuine” fake passports — original, blank booklets stolen from a government office in Syria to be filled with the black market buyer’s personal information — for $1,300. University degrees, which may come in handy for a job application, sold for $1,000.

Until recently, Syrians in exile seeking new or renewed passports often had to travel to regime-controlled areas within Syria — a major security risk for anyone who left the country as a refugee. In an apparent effort to counter the spread of fakes, the Syrian government said this spring its embassies would issue passports to Syrians abroad “even if they left in an illegal manner or they hold non-official passports or travel documents,” according to the pro-government Al-Watan newspaper.

But many Syrians do not trust their government and still prefer illicit routes of obtaining paperwork — particularly if they think they’re wanted by the regime.

Thirty-two-year-old Mohammad fled Syria with his wife and son, Rami, two years ago after he defected from the military.

“I decided to leave when I knew I was going to be ordered to shoot at people,” said Mohammad, who now lives in the southern Turkish city of Mersin. The family left Syria without documents such as their marriage license and Rami’s birth certificate. They are now having trouble registering the 3-year-old boy for a refugee ID card, which would grant him access to healthcare, education and social services. But because he defected, Mohammad said he cannot go to the Syrian consulate.

“I need to prove that he’s my son to Turkish authorities and I don’t have any legal document that does that,” Mohammad said. He is now awaiting a forged birth certificate, which cost $1,000.

Young children are especially vulnerable in the missing-documents crisis. Most countries to which refugees flee do not grant automatic citizenship to babies born there. This puts refugee children at risk for statelessness — and potential trouble returning home when the fighting ends.

Amid the huge market for fakes, Syrians with true passports may have trouble proving to authorities they are real. Two weeks ago, Fabrice Leggeri, head of Europe’s border agency Frontex, warned of a growing market for stolen or fake Syrian passports among non-Syrian migrants. Because of the ongoing war in their country, Syrians are far likelier to be granted international protection in their first application, according to Eurostat. The preferential treatment means their passports command top dollar on the black market.

“There are people who are in Turkey now who buy fake Syrian passports because they know Syrians get the right to asylum in all the member states of the European Union,” Leggeri told a French radio station.

When 22-year-old Ashraf Hammoud and his girlfriend, both Syrian refugees from Aleppo, decided to go to northern Europe from Turkey with the help of a smuggler, they faced two choices for a route. They could take a boat from Turkey, then start the long walk through the Balkans, Hungary and Austria. Or they could fly, an expensive but less dangerous option that would require fake travel documents.

They decided on a combination. They first paid $1,500 each for spots in a boat from the Turkish coast to a small Greek island called Pserimos. “After that, everything got easy,” Hammoud said.

A second smuggler in Athens mailed them two fake Portuguese national ID cards for 100 euros apiece. They dressed as tourists and visited a hairdresser to spruce themselves up after hiking across another Greek island en route to an airport. “Really we didn’t look like refugees at all,” said Hammoud, who wears earrings and uses fluent American Millennial-speak.

It worked. The pair flew to Amsterdam and claimed asylum in the airport upon arrival.

Interviews with four refugees who were found out while using fake documents show the stakes for getting caught are low. Border authorities usually hand back the forged documents, now worthless.

Hammoud said that when a friend tried to use a bad fake ID to board a plane in Greece, “The airport lady said to them literally, ‘Try again.'”

For Obaida, his second, cheaper fake passport worked much better than the first. Recently he left and reentered Turkey. Last week, he contacted this reporter via social media to proudly show off his official Turkish entry visa. And with a string of happy-face emojis, he declared: “I made it.”

Mowaffaq Safadi contributed reporting.