This page is no longer maintained and may be inaccurate. For more up-to-date information, see the Internationalization Activity home page.
ISO 3166 contains 2-letter codes for each country, and UN M.49 contains a set of 3-digit region codes.
You can find the latest codes together in this lookup tool for the IANA Language Subtag Registry. You can also find the 2-letter ISO 3166 codes at official list of ISO 3166-1 country codes.
If you are looking for country codes in order to qualify language tags, you should see Language tags in HTML and XML.
Note that Internet top-level domain names use almost the same codes, but not quite (eg. the ISO code for the United Kingdom is GB, whereas the internet TLD is UK).