For example: someone places an advertisement to sell a mobile phone for 100 dinars, and I put this ad on the Internet. Then someone asked me on the Internet whether I would agree to sell it for 90 dinars.
Then I get in touch with the one who placed the ad and offer him 80 dinars, and he agrees to sell me the phone (for that price).
Then I contact the person who offered 90 dinars and agree with his price. Then I buy it for 80 and sell it for 90, thus making a profit of 10 dinars.
If the questioner does not sell the phone to the one who wants to buy it until after he has bought it and taken possession of it, and then sells it, there is nothing wrong with that.
But if he sold the phone before taking possession of it and completing the purchase transaction with the first owner, this kind of trade is not permissible, because it is not permissible for a person to sell something that is not in his possession, and it is not permissible for him to sell what he has bought until he has taken possession of it and moved it to his place. It was narrated that Hakeem ibn Hizaam (may Allah be pleased with him) said: I came to the Messenger of Allah (blessings and peace of Allah be upon him) and said: A man may come to me wanting to buy something that I do not possess; should I buy it for him from the marketplace then sell it to him? He said: “Do not sell that which you do not possess.”
Narrated by at-Tirmidhi, 1232; an-Nasaa’i, 4613; Abu Dawood, 3503, Ibn Maajah, 2187, Ahmad, 14887. Classed as saheeh by al-Albaani in Irwa’ al-Ghaleel, 1292.
It was narrated from Tawoos from Ibn ‘Abbaas (may Allah be pleased with him) that the Messenger of Allah (blessings and peace of Allah be upon him) forbade selling foodstuff until one has received it in full. I [the narrator] said to Ibn ‘Abbaas: Why is that? He said: Because they are exchanging dirhams for dirhams, but the delivery of food is delayed?
Narrated by al-Bukhaari, 2132; Muslim, 1252
Ibn Hajar said in Fath al-Baari, 4/349: What is meant is that he was asking about the reason for this prohibition, and Ibn ‘Abbaas replied that if the purchaser sells it before taking possession of it when the item is still in the possession of the seller, it is as if he sold dirhams for dirhams. This is explained by what is mentioned in the report of Sufyaan from Ibn Tawoos that is narrated by Muslim. Tawoos said: I said to Ibn ‘Abbaas: Why is that? He said: Don’t you see that they are exchanging gold, but the delivery of food is delayed? i.e., if he buys foodstuff for one hundred dinars, for example, and he gives the money to the seller but does not take the foodstuff from him, then he sells the foodstuff to someone else for one hundred and twenty dinars and takes it from him when the food is still in the possession of the (first) seller, then it is as if he sold one hundred dinars for one hundred and twenty dinars, it looks as if he sold one hundred dinars for one hundred and twenty. According to this interpretation the prohibition is not restricted only to foodstuffs. Hence Ibn ‘Abbaas said: I think that all things are like this. And this is supported by the hadeeth of Zayd ibn Thaabit, according to which the Messenger of Allah (blessings and peace of Allah be upon him) forbade selling a product in the place where it was bought until the merchants have taken it to their own places.
Narrated by Abu Dawood; classed as saheeh by Ibn Hibbaan. End quote.
Al-‘Ayni said in ‘Umdat al-Qaari (11/250): What this means is: If he buys some food from a man for one dirham to be delivered later, then he sells it back to him or to someone else before taking possession of it for two dirhams, for example, that is not permissible because it is in effect selling cash for cash, when the food is not there. So it is as if he sold his dirham with which he brought the food for two dirhams, which is riba, because it is selling something that is not there (not in the possession of the seller) for cash. So this (transaction) is not valid. End quote.
Shaykh Ibn Baaz said: It is not permissible for a Muslim to sell an item for cash or credit unless he owns it and has taken possession of it, because the Prophet (blessings and peace of Allah be upon him) said to Hakeem ibn Hizaam: “Do not sell that which you do not possess.” And he (blessings and peace of Allah be upon him) said, according to the hadeeth of ‘Abdullah ibn ‘Amr ibn al-‘Aas (may Allah be pleased with him): “It is not permissible to take a loan and sell at the same time or to sell that which is not in your possession.” Narrated by the five with a saheeh isnaad. Similarly, the one who buys it does not have the right to sell it until he also takes possession of it, because of the two hadeeths quoted above and because of the report narrated by Imam Ahmad and Abu Dawood, and classed as saheeh by Ibn Hibbaan and al-Haakim, from Zayd ibn Thaabit (may Allah be pleased with him) who said: The Messenger of Allah (blessings and peace of Allah be upon him) forbade selling a product in the place where it was bought until the merchants have taken it to their own places. And because of the report narrated by al-Bukhaari in his Saheeh from Ibn ‘Umar (may Allah be pleased with him), who said: I saw the people at the time of the Messenger of Allah (blessings and peace of Allah be upon him) trading in foodstuff without measuring it, and they would be punished if they sold it before moving it to their own places. And there are many hadeeths on this topic.
End quote from Majmoo‘ Fataawa ash-Shaykh Ibn Baaz, 19/64
And Allah knows best.