The main difference between gills and lungs is that gills are the type of respiratory organs specialized to breathe in water, whereas lungs are the type of respiratory organs specialized to breathe in the air. Furthermore, fish use gills while mostly tetrapods use lungs.
Lungfish have a unique respiratory system, having both gills and a lung. It is the only type of fish to have both organs, not only does it help them to survive, but may also be key to the evolutionary origins of the lung. Granddad is the oldest fish we know of anywhere in the world, and there are only six known species around the world.
The advantages of having both lungs and gills gives a better chance of survival above and in water.