Is it permissible for the borrower to promise the lender a gift when paying off the loan?
Question

If a friend borrowed some money from me then said to me: When I give it back to you I will give you something in appreciation and he did not state a particular amount, is this regarded as a kind of riba or not?.
Praise be to Allah.If the borrower gives back more than he took without any prior stipulation or agreement at the time of taking the loan, there is nothing wrong with that. There are a number of hadeeths that speak of that. 
Al-Bukhaari (443) and Muslim (715) narrated that Jaabir ibn ‘Abdullah (may Allah be pleased with him) said: I came to the Prophet (blessings and peace of Allah be upon him) when he was in the mosque and he said: “Pray two rak‘ahs.” And he owed me a debt, so he paid me back and gave me something extra. 
Al-Bukhaari (2305) and Muslim (1601) narrated that Abu Hurayrah (may Allah be pleased with him) said: A man was owed a young camel by the Prophet (blessings and peace of Allah be upon him) and he came to him to ask him to pay it off. He said: “Give it to him. They looked for a young camel and they could not find anything except one that was of older than it. He said: “Give it to him.” And he said: You have paid me off, may Allah reward you. The Prophet (blessings and peace of Allah be upon him) said: “The best of you are those who are the best in paying off debts.” 
Muslim (1600) narrated from Abu Raafi‘ (may Allah be pleased with him) that the Messenger of Allah (blessings and peace of Allah be upon him) borrowed a young camel from a man, then some zakaah camels were brought to him. He told Abu Raafi‘ to give the man back his camel, and Abu Raafi‘ came back to him and said: I could not find anything among them but camels that were better and older. He said: “Give it to him, for the best of people are those who are best in paying off their debts.” 
But if that was done by prior agreement, it is not permissible to give the extra amount or to accept it, because it is one of the forms of riba. 
It says in al-Mawsoo‘ah al-Fiqhiyyah, 23/125: 
The majority of Hanafi, Shaafa‘i and Hanbali fuqaha’, and Ibn Habeeb among the Maalikis, and others, are of the view that if the borrower pays the lender back with something that is better than it in amount or quality, or something that less than it, with the consent of both parties, it is permissible so long as that happened without any prior stipulation or agreement. End quote. 
The scholars of the Standing Committee for Issuing Fatwas said: 
The lender has no right to take from the borrower anything but that which he lent to him, unless the borrower willingly gives something extra in quality or quantity. So there is nothing wrong with it so long as there was no prior stipulation or agreement to that effect. The same ruling applies if this is done on the basis of custom, because a customary stipulation is the same as a verbal stipulation. End quote. 
Fataawa al-Lajnah ad-Daa’imah, 14/134 
Based on that, it is not permissible for the borrower to promise the lender that he will give him a gift when paying it off; he may give him that if it is done without prior agreement. 
And Allah knows best.