Viewed from Egypt, it’s clear what Turkey is up to in the Middle East.

For one thing, Israel is no more than a foil in Turkey’s well-played drama.

Once, Turkey was Israel’s most prominent ally in the non-Arab Islamic world. Israel trumpeted that alliance, proud of the fact that it could maintain friendly economic and even military relations with a large Islamic nation like Turkey.

Now that’s gone.

The natural reflex in Israel is to ask, “What did we do wrong?” and “what can we do to fix this?”

From here, the answers look simple. “Nothing” and “nothing.”

For the past decade, Turkey has been shifting its focus, its self-identity. If once Turkey aligned with the West, it is now aiming to be a Mideast power, and it is succeeding.

Turkey is a NATO member, but it is not in the European Union. Its rejection by the EU, ostensibly over its Islamic orientation, triggered the shift. Since then, there have been several public, nasty spats between Turkey and NATO, tempered by recent cooperation over the Syria crisis.

And all the while, Turkey has been aiming to bolster its image and standing in the Arab world.

There is one guaranteed method to achieve that: Bash Israel. Turkish Prime Minister Recep Tayyeb Erdogan has become a master of the practice.

His most celebrated ploy was to provoke Israel’s only living Nobel Peace Prize laureate, President Shimon Peres, into a shouting match over Gaza, and then storm off the stage of the world economic summit in Davos. That was in January 2009.

The ugly saga of the Mavi Marmara, when Israeli forces boarded the Turkish ship headed for Gaza to break the Israeli blockade and killed nine activists, played into Erdogan’s hand. So did the silly maneuver of Israel’s deputy foreign minister, Danny Ayalon, publicly embarrassing the Turkish ambassador to Israel. Erdogan could not have scripted those incidents better himself.

As a result of his anti-Israel grandstanding, Erdogan is received as a hero all over the Arab world. Egyptians cheered and celebrated when he visited Cairo last November.

But Turkey’s act is not all for show.

Last year Turkey offered Egypt a $1 billion credit line, and Egypt gladly accepted. Its foreign currency reserves have plummeted below the danger line, and any help is welcomed. Turkey has invested $1.5 billion in Egypt and pledges to increase that substantially.

A recent edition of an Egyptian monthly magazine I read regularly, Business Today, devoted its cover story to burgeoning Egypt-Turkey economic relations. The two countries have signed no fewer than 27 trade agreements, and trade has increased 30 percent over the past year.

Business Today’s cover story is headlined, “Long Overdue Alliance.” It focuses on a retail trading concern expanding its business with Turkey, playing up the almost unlimited potential of the Egyptian consumer market. Overplaying, perhaps — while there are, indeed, about 84 million people in Egypt, the World Bank says 40 percent live near or under the international poverty line of $2 a day, and they are not buying much from anyone.

The article lists five regional trading accords involving Egypt, the EU, Turkey, Africa, the United States and Arab nations. To illustrate, it shows this map:

lavie mag copy 2

Look what’s missing. Not just “Israel.” Also, an arrangement that has revolutionized Egyptian textile exports — the Qualifying Industrial Zones (QIZ) accord signed by Egypt, Israel and the U.S.

It allows Egypt to export its products customs-free to the U.S., as long as they have 10.5 percent Israeli input. It’s a bit more technical than that, but those are the bare bones.

The pact went into effect in 2005. Since then, more than 700 Egyptian companies have taken advantage of it, and they bring in more than $1 billion a year, according to the Egyptian government.

There was some speculation that the Muslim Brotherhood would try to cancel the deal when it took power here, but just the opposite — Egypt has been negotiating with Israel to lower the Israeli component a bit. That amounts to an indirect endorsement of the pact.

That’s because the Muslim Brotherhood is not suicidal. Business Today, in the same edition that prints that map, notes that the textile industry employs more Egyptians than any other sector — no less than 30 percent of the work force. The QIZ is a crucial element in that. This month the U.S. expanded it to include more Egyptian firms.

Responding to my question, the deputy managing editor of Business Today said the map was just an illustration of the nations that have free trade agreements with Egypt. Without my asking, he said the QIZ pact isn’t in that category.

So Turkey gets the magazine cover, and on a larger scale, the public adulation. Turkey is the one making noise, much of it directed against Israel. For better or worse, that’s the key to popularity in the Arab world. And that is Turkey’s aim. Israel is just a means to the end.

That’s why there is nothing Israel can do to improve relations, at least in public. No apology over the Mavi Marmara could ever be acceptable, if the Turkish goal is to use Israel as a way to fame and fortune in the Arab world. No diplomatic move, economic offer or tourism deal will change that.

What needs to be understood here is this: Just as there are two sides to the Israel-Palestinian conflict, and not everything depends on what Israel does — there are two sides to the Israel-Turkey conflict, and not everything depends on what Israel does.

So the most beneficial policy for Israel would be to sit back and do nothing. Do nothing to provoke, and do nothing to promote, at least in public. As with Egypt, there might be opportunities to develop relations behind the scenes, if they are in the best interests of both countries.

Like the QIZ. It works so well because it’s the “peace treaty” no one has heard of.