The other class of foreigners is nonresident aliens and it concerns people not authorized to live or work in the US but who can come to the US regularly on a short basis such as less than three months (tourist visas fall into this category).
In order for them to be granted a loan in the US, they will have to develop a suitable credit history, which can take a while. The credit history of a person is formed by the credit bureau which gathers information from several different sources, and is waived if a down-payment of 30% (sometimes just 20%) of the total price of the property is made.
A few financial institutions will set the loan-to-value ratio (LTV computed by dividing the loan over the price of the house) to a maximum limit (e.g. 60%) for a minimum price of property (e.g. $200,000). This means that 40% of the price will have to come from the buyer's own assets ($80,000 for a minimum price of $200,000) or, that the buyer will have a second loan in their home country (which is legal). This is why it can be advised to try to obtain a mortgage before leaving for the US for non US resident. A higher down-payment like this, forced by an upper-bound limit to the LTV ratio, increases on the other hand the chances of being accepted for a mortgage in the US.
Moreover, foreigners can face other difficulties when being granted a loan in the US. They will have to provide the lender with proof of income and credits (as any other US citizen), but many US lenders tend not to accept foreign paperwork (even coming from credit bureaus) attesting these data. To get around it, and apart from the two other options already mentioned of getting a loan in one's home country or building a credit history, a hard money loan can be sought after. A hard money loan means that the loan is secured by the value of the real estate (it is similar to some extent to the lender acquiring part of the property in case the borrower defaults), and has two disadvantages. Firstly, interest rates are higher, and secondly, a down-payment between 40 and 50% will be usually required.
Last, different states have different rules and regulations regarding loans, and since each case is different, more specific and detailed information should be sought after on a individual basis.