Why could China, much poorer than US, lend so much money to US? The GDP per capita of China is only a fifth of that of US.
But China has lent more than a trillion dollars to US.

How could the much poorer China lend so much money?
Where did those money come from?
You don't have to be richer than someone to lend them money. You only need to have money to lend. China has a lot of money to lend because it has a high savings rate. In the past, it preferred to lend the money to the US, because that would allow the US to buy more goods from China. However, the situation is now changing.