Question: I have two different pictures of the same object, one of which is taken from roughy the same angle but has a different scale and rotation. I want both images to overlap so that the upper one matches the lower one as exactly as possible. Is there any option in gimp where I can define a number of key points and gimp aligns the images according to these points? For example I say that corner X in picture 1 has to match corner Y in picture 2. It should be sufficient to define 3 such points in each image to get a good result already.

If it is not possible, what would be the best way to reach this goal aside from just scaling and rotating until it looks ok?

Answer: 
It looks like [panotools](http://panotools.sourceforge.net/) has a [Gimp plugin](http://sourceforge.net/projects/panotools/files/gimp%20plugin/). I haven't used it, but it's there.

Outside of GIMP, but still free, you might want to try going down different roads.

[**Hugin**](http://hugin.sourceforge.net/) - Primarily targetted at panorama stitching, you can use this to [align and scale an image stack](http://wiki.panotools.org/Align_image_stack) for HDR or exposure blending or time-lapse videos or...

[**Registax**](http://www.astronomie.be/registax/) - Aimed at astrophotographers, this free software will take multiple images (a few stand-alone or thousands of video frames), rotate, scale, and align them. Beyond that, it can (optionally) use very sophisticated techniques to combine the component images into a final image.

[HDR Alignment Tool](http://www.flickr.com/photos/58368129@N00/210213524/) - Another possibility. It does alignment, rotation, and scaling. Might be worth a try. A [comparison](http://www.flickr.com/photos/longjiang/531171093/) to Photomatix auto-alignment (in 2007, mind you) seems to favor HDRAT.

[DeShaker](http://www.guthspot.se/video/deshaker.htm) - Another way to approach aligning smaller images (up to 1080p resolution), this free software does video stabilization. If you were to combine the two images into a two-frame movie, this would align them. Probably not what you want, but it's a technique that's been used for aligning still images.
I just did this in Gimp with no additional software. This method will easily and precisely produce the "3 point scale, rotate, translate" that you asked about. If there's other perspective issues though, one of the other methods in the other answers will be required.

1. Both images in their own layer. Select the ruler.
2. Show Layer1/Image1, measure between two points. Click and drag from one point to another, then zooom in and move the endpoints for more precision. This gives you the exact measurement to a tenth of a pixel and the rotation angle. The further apart the points, the better. Let's call it Length1.
3. Show Layer2/Image2. Adjust endpoints to match the same reference points. Let's call it Length2.
4. 100 \* (Length1/Length2) = The scale percentage you need to apply to Image2.
5. Rotate as needed, as indicated by the difference in rotation angles.
6. It's a simple matter to move one image over the other.