From the FAQs:
NSF rarely provides support to foreign organizations. NSF, however, will
consider proposals for cooperative projects involving U.S. and foreign organizations, provided support is requested only for the U.S. portion of the
collaborative effort. For further information, contact the Office of International Science and Engineering. (Reference GPG Chapter I.E.6.)
Individual funding opportunities list specific eligibility requirements. These generally say something like "The PI must hold an appointment at an eligible US institution."
There is an office of the NSF specifically devoted to encouraging international collaboration, and there are often specific funding opportunities earmarked for collaboration with a particular country. You'll find examples of many such opportunities on the linked page.
Having said that, it's not impossible for NSF money to trickle down to foreign researchers. For example, I am at a US institution and I participate in a project supported by the NSF, in which our budget includes a subcontract arrangement involving researchers in Australia. As far as the NSF is concerned, this money is paid to a US institution (mine), but we are allowed to use some of it to pay our foreign colleagues as subcontractors. (The details of this arrangement were of course specified up front in our proposal.) Specific grants may have different requirements with respect to subcontracting to foreign institutions.