The 11th Amendment establishes state immunity against foreign prosecution. The amendment actually does not grant immunity but clarifies Article III Section 2 of the Constitution, which addresses the states and non-citizens.
The 11th Amendment also protects the states from foreign prosecution from other governments. The amendment was added in 1795 in response to the U.S. Supreme Court case Chisholm v. Georgia, which allowed a resident of South Carolina to file a lawsuit against Georgia. The amendment was first proposed in 1794 and was ratified by most of the states in 1795 in response to the case. South Carolina ratified the amendment in 1797, but Pennsylvania and New Jersey did not.
The amendment specifically protects the states from having to pay monetary compensation without state consent. The 11th Amendment is a measure that is meant to preserve state sovereignty, but Congress still holds some authority at the national level. For instance, Congress is allowed to waive state immunity in cases involving the 14th Amendment, particularly the Section 5 clause.
Congress is also allowed to nullify immunity in regards to bankruptcy cases. This exception came in response to Central Virginia Community College v. Katz, a case in which the courts cited Article I Section 8 Clause 4 of the U.S. Constitution as a valid reason for nullification. The 11th Amendment also does not protect states from suit against its own citizenry.