The Difference between Loan and Sale in Islam
Question

I received from a sister an amount of gold as a Qard Hasan (goodly – i.e., interest-free – loan), and I promised to return it after some time in the form of gold (of the same weight). I hope that you can explain to us: does this come under the heading of Riba (interest, usury)?
Praise be to Allah.Islamic Teachings on Riba and Trade
There are many Hadiths from the Prophet (blessings and peace of Allah be upon him) which describe the types of Riba, including the hadith of `Ubadah ibn As-Samit (may Allah be pleased with him), who said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Gold for gold, silver for silver, wheat for wheat, barley for barley, dates for dates, salt for salt, like for like, same for same, hand to hand. But if these commodities differ, then sell as you like, so long as it is hand to hand.” (Narrated by Muslim, 1587)
The Permissibility and Purpose of Loans in Islam
Giving loans is permissible and is recommended, according to the consensus of the Muslims, whether it involves the types of wealth that are subject to Riba or others.
Ibn Al-Qattan (may Allah have mercy on him) said in Al-Iqna` fi Masa’il Al-Ijma` (p. 197): All of the scholars from whom I acquired knowledge unanimously agreed that borrowing Dinars and Dirhams, wheat, barley, dates, gold and similar types of food that are weighed and measured is permissible. (End quote)
Common Misconceptions Regarding Loans and Sales
The questioner is confused by the fact that it is a loan of gold for gold, and thinks that it is a type of exchanging a kind of wealth that is subject to Riba when the exchange does not take place on the spot.
The response to that includes noting several points:

The texts which stipulate that the exchange occurs on the spot, “hand to hand,” only refer to buying and selling: “then sell as you like.” There is no mention here of loans.
The loan is intended to be an act of kindness and help, in contrast to a sale or transaction, which is an exchange of wealth without anything to be returned later on.

Ibn Al-Qayyim (may Allah have mercy on him) said in I`lam Al-Muwaqqi`in `an Rabb Al-`Alamin (2/11):
With regard to loans, those who say that the loan is an exception to the ruling are mistaken in thinking of the loan as an exchange of wealth of the same type that is subject to Riba, without the exchange taking place on the spot. This is mistaken, because the loan is a kind of giving some wealth to someone else, so that the latter may benefit from it and then return it. Hence the Prophet (blessings and peace of Allah be upon him) called it a Manihah (an item loaned as a favour), as he said: “Whoever gives a Manihah of gold or a Manihah of silver…” This comes under the heading of showing kindness and helping, not of exchanging wealth. Buying and selling is based on the idea of exchanging wealth that is not taken back, whereas loans come under the heading of lending and Manihah… this has nothing to do with the idea of buying and selling; rather it comes under the heading of showing kindness, and giving gifts or charity. End quote.
Shaykh Ibn `Uthaymin (may Allah have mercy on him) said in Ash-Sharh Al-Mumti` `ala Zad Al-Mustaqni` (9/93):
It is a kind of deal based on kindness and for the purpose of helping, in which the borrower is temporarily given possession of the  borrowed item. In other words, you temporarily give possession  of what you give as a loan to the man who borrows it. … Thus it is a transaction for the purpose of helping, and it is not intended as an exchange or to make a profit; rather it is based on pure kindness. Hence it is permissible to give a loan on this basis, even though it may look like a Riba-based transaction, because if a man sells a Dirham for a Dirham but the exchange does not take place on the spot, then it is Riba, but if he lends him a Dirham and a month later he returns it to him, that is not Riba even though it may look like Riba, and the only difference is the intention behind this process. As for the purpose of the loan, it is to help and show kindness to another, and it is permissible.

It is known that people have been lending money, Dirhams, Dinars and all kinds of wealth and items, such as barley and camels, to one another, and paying back with the same calibre of wealth, since the time of the Prophet (blessings and peace of Allah be upon him) until the present day, and nobody said that this is Riba. It was narrated that `A’ishah (may Allah be pleased with her) said: The Messenger of Allah (blessings and peace of Allah be upon him) bought some food on credit from a Jew, and he gave him an iron shield of his as collateral (Rahn). (Narrated by Al-Bukhari, 2251 and Muslim, 1603) – and barley is one of the types of wealth that are subject to Riba.

If we were to stipulate that the exchange take place on the spot in the case of loans, there would be no lending of any of the types of wealth that are subject to Riba.
And Allah knows best.