Loan rejection stays on your credit history for a longer period of time, but this does not mean that it will impact your credit score. While being declined on a loan has no affect on credit scores, the general recommendation is to still avoid rejection if possible.
On the one hand, if you handle debt inappropriately, it will stay on your credit report for years and have an impact on your credit score, and that can cost you a lot over a long period. That said, the older your mistakes get, the less impact they'll have on your credit score.
On the other hand, there are other items that can appear in your credit history that might have an insignificant effect on your credit. One of those comes when your loan application is rejected.
According to Experian, which is one of the three leading credit reporting agencies, a credit report won't show whether or not a loan application is approved or declined, which means that being rejected has no effect on credit scores.
That said, in most cases when you apply for a loan, an inquiry does appear on your credit report because it indicates that you have applied to take on more debt. From the perspective of credit reporting agencies, the potential new debt means additional possible risk, so the inquiry itself can have a minimal negative impact on your credit score.