I have replaced my iphone 3G's battery as it was nearly two years old and not lasting that long.
I got the battery from eBay for approx £5.
There are many sites explaining how to open the iphone ....you need to go as far as taking the motherboard off ...once that is done your battery is exposed.
One thing which I have not seen mentioned is that the battery has a 4 pin edge connector, this is screwed on to a spring loaded connector.
The replacement battery came with a separate connector which was loose.
What I did do is unsolder the old edge connector and soldered it to the new battery as I was not sure how the spring would come off. So with a solder iron and some solder I swapped the edge connector and fitted the battery. Make sure you connect the edge connector as the old one was, otherwise it will not sit properly on the motherboard.
Here are some pictures:
The four pins on the ribbon cable connect to battery.
You will to solder these on (check the orientation on the original battery before you do this).