1. The first step is to activate the color to alpha plug-in. Its menu location is <image> Filters -> Colors -> Color To Alpha, where <image> means to right click on the image. If its grayed-out, it means that you have an indexed image. If its not there, upgrade your gimp to 1.2.x.
2. Next use the Color Picker Tool to select the background color. Or just open the toolbox (Tool -> Toolbox) and choose the background color from the last image. Then choose Layer -> Create New Layer, and choose "Foreground color".
3. (Optional) When you used the color picker to select the background, a window with the color popped up. Click, hold, and drag from the color portion of this window to the color portion of the Color To Alpha plug-in. If using Gimp for Windows, you'll have to right-click on the destination button and select the Foreground - drag n' drop doesn't work. Click OK after the color indicator on the Color To Alpha plug-in is changed to blue. Alternatively, make sure that the "color to alpha" is selected when you did Step 1.
4. Now create a New Layer as a Background. The background will now come on top of your image, but don't worry because your image is just layered beneath. Choose "Layer -> Stack -> Reverse Layer Order".
5. Remove the layers: Image -> Flatten.
6. If you want to change your image resolution, do: Image>Print_ Size>Set_Image_Print_Resolution.
(tutorial written according to this link)