My question is in relation to CFD (Contract for difference) trading which is quite common in western countries. I would like to understand if such agreements are allowed . For clarity and simplicity I have defined the nature of this agreement with an example below:

According to CFD trading, two people enter into an agreement whereby one person agrees to pay the other person difference between the movement in price of an item without actually owning the item. Such item could be anything like gold, silver, currency, shares etc. For example Mr A agrees with Mr B that if the price of gold increases, Mr B would pay such increase to Mr A and if the price decreases Mr A would pay such difference to Mr B. Neither Mr A nor Mr B actually owns gold however only want to sepculate on the movement of gold price. I would like to understand if such agreements are allowed according to Islam or are they a form of gambling?

So if we examine the rulings scholars have given for “betting” and what constitutes “betting,” it appears to me that this is a type of betting. Neither of them owns the gold, and so the money involved is purely for speculation. This is betting and so it’s haram.

Yes, if one is being paid to professionally speculate it’s fine. A company may hire an analyst to speculate future prices. This is permissible. But in the example you provided it’s betting.