Can you get a visa to the US if you are in another country as a visitor? For example, you're from Algeria and visiting Germany. Are you allowed to apply for a visa at a US Embassy or Consulate in Germany?
I am a citizen of another country who would like to apply for a visa while in Thailand. Can I do so?
While it is the policy of U.S. Embassy Bangkok to accept visa applications from anyone physically present in our consular district, we strongly recommend that you make your application in your country of nationality or residence. Should you choose to apply in Bangkok, and you are not a Thai citizen or a long-term resident of Thailand, it may be quite difficult for the adjudicating consular officer to make a determination regarding your case. Additionally, while many visas are able to be issued within 3-4 business days of the interview, if there are any delays it could have a significant impact on the timing of your return travel.
So, the answer to your question is yes, you can get a visa to the US if you are visiting another country, but the application might take longer than it would if you applied in your country of residence, and the probability of success may be lower.
It has become apparent in the comments that you intend to marry the visa applicant in the US:
My friend has applied in his country, Algeria, and has been denied both times. They keep saying it's because they think he wants to marry. The last time he went they told him do not apply again for 3 years... I am at a loss for what to do to help him. – GIGI SMITH
@GIGISMITH applying in Germany won't help overcome the factors that led to the refusals in Algeria. – phoog
Thank you phoog. I am just at a loss at how to help. I guess we will try a fiance visa since this is what they believe. – GIGI SMITH
@GIGISMITH are you in fact going to marry? – phoog
Yes. We wanted to meet and come back to US for marriage. We do not think they will accept this either. It is just difficult to get his visa. He has tried twice in the past 8 months but only trying tourist visa. – GIGI SMITH
If the intention is to settle in the US, then the previous visa refusals were correct because a tourist visa is the wrong visa for that purpose. If that is your intention, however, the question is off topic here; you should ask instead at Expatriates.
If the intention is to leave the US after you marry, then you should be up front about your intentions. In that case you will need compelling evidence of concrete plans to build a life outside the US. This is necessary because the law requires applicants for nonimmigrant visas to overcome a presumption that they intend to immigrate.
Another option would be to get married in another country and then apply for an immigrant visa as the spouse of a US citizen (assuming you are in fact a US citizen).
Finally, you may have created a bit of trouble for yourself already, however, since referring to someone you intend to marry as a "friend" can seem deceptive. Applying for a fiance visa after two refused tourist visa applications could call your credibility into question. If you can afford one, now is probably the time to engage a reputable immigration lawyer.