Generally, yes (at least in the United States). The question of which court a lawsuit should be filed in is often one of convenience when the lawsuit is filed; it is not that unusual for this to be a different jurisdiction than the natural jurisdiction when the contract was made. For instance, here is a case in which two US soldiers got into a car crash while stationed in Germany, and one sued the other in Oklahoma court when they returned home. The plaintiff also sued the defendant's insurance, which was allowed under German laws but not Oklahoma laws. However, the Oklahoma Supreme Court determined that the contract was intended to be governed by German law (since it was sold in Germany), and so it made sense to apply the provisions of German law to the contract.
There are exceptions. Courts can decline to enforce terms that are contrary to local public policy; for instance, no US court will enforce a contract that amounts to indentured servitude. For a more common example, employment contracts can have non-compete clauses. In California, those contracts are considered to be against public policy, and are unenforceable regardless of what law the contract was made under. But those are the exceptions; in general, US courts are perfectly willing to hear a case and apply foreign law if it makes sense to apply the foreign law and to hear the case in the US.
This actually comes up a fair bit in the US: each of the 50 states and the federal government have their own laws, and it's not unusual for multiple jurisdictions to be reasonable places for a lawsuit. If a contract is signed between two parties in Maryland, but one party is a resident of Pennsylvania, a lawsuit over it could potentially be filed in federal court. In that case, federal procedures are followed, but the actual law applied would pretty much be Maryland law.