If you have Android 4.0 or higher:
You can press the Power button + the Volume Down button at the same time to take a screenshot. It will be saved to your gallery.
Note: You need to keep the buttons pressed for around a second for this to work. This is to avoid the screenshot when this combination is accidentally pressed.
UPDATE 8.3.2021: If you have Android 10, you must press the Power button + Volume Down buttons ONLY BRIEFLY (< 0.5 seconds). If you press them longer, the Power menu will just open and the screenshot will not be captured.
If you have an Android lower than 4.0:
If you’re rooted: you can install an app called drocap2. This will let you shake your phone, wait on a timer, or click on a notification in your notification bar to take a screenshot and it’ll save it to your phone.
If you’re not rooted: you can not run a screenshot app on your phone, period. You’ll have to install the Android SDK on your computer, connect you phone via USB, and run a program called DDMS. This program is mainly used for developer debugging, but it has a screenshot utility under one of its menus. For a tutorial, see this page.
Also, some constructor like Samsung have implemented this function on their phones (the buttons combination change from phone to phone, so search for yours).
Screenshot via Volume-Down + Power device keys
Starting with Android 4 Ice Cream Sandwich there is finally a possibility to create a screen-shot without 3rd party app or connected computer:
Press the following two keys at the same time: Volume-Down + Power
Note that it is crucial to press both keys nearly the same time. If your press and hold Volume-Down and afterwards press Power it will not work. (tested on Galaxy nexus 4.1.2)
Screenshot via Shutdown/Restart menu
On newer devices (Android 8+) there is also a button for creating a Screenshot in the menu that allows you to power down or restart the device (usually reachable by pressing the power button ~2 seconds).
However some screens are protected and therefore can not be captured, e.g. some system settings dialogs.
In the Galaxy S Froyo (Android 2.2) you can take screenshots by holding the back key and tapping the home button.