An idiom is a fixed phrase whose meaning you cannot work out from its words, such as kick the bucket. A metaphor describes one thing as if it were another, unrelated thing, and the context usually tells you what it means. That is the main difference between idioms and metaphors.
Some things happen literally, and some happen only figuratively speaking. For the second kind, people often fall back on idioms or metaphors to describe a situation, their feelings, or an event.
Idioms and metaphors are a creative and colorful way to express yourself, but they are also easy to confuse. Yes, there is a difference between the two. This article explains what it is and how to tell an idiom from a metaphor.
Metaphors
A metaphor links two things that usually do not go together. Instead of making an open comparison, it carries a hidden meaning: it says that something is like, or even is, something otherwise completely unrelated.
Examples of metaphors
He may be big, but he's a gentle lamb.
Figuratively, the man is given the qualities of a small lamb. What the sentence means is that he has a kind, mild nature. If you say as gentle as a lamb instead, the comparison is open, made with as or like, and it is called a simile rather than a metaphor.
My daughter is the apple of my eye.
The speaker's daughter is, of course, not literally part of their eye. The phrase says that the daughter is loved and cherished above everything else. This metaphor is so common that it has also become an idiom.
When faced with a complicated problem, he develops tunnel vision.
Tunnels are dark and leave little room to look around. With this metaphor, the speaker says that the man focuses on one thing only, just like someone looking through a tunnel, for whom all that matters is the exit at the other end.
Idioms
Idioms don't follow a pattern the way metaphors do. Their literal meaning often makes no sense, and yet most people (at least native speakers) know what they mean. Idioms that are used too often become clichés, and you should avoid those in your writing unless you really need them, or your text will sound tired. Not every cliché is an idiom, though.
Examples of idioms
He kicked the bucket.
"So what?" you may ask if you don't know this idiom. It does not mean that a man literally kicked a bucket: it means that he died.
It's raining cats and dogs.
This does not mean that these beloved pets are falling from the sky, but that it is raining very heavily.
Break a leg.
This idiom is very common in the theater. One actor does not really wish another to break a leg during the performance: it is simply a way of saying "good luck".
For the stories behind more fixed phrases, read about proverbs and the phrase caught red-handed.
The difference between idioms and metaphors
The biggest difference may be that you can usually work out the meaning of a metaphor from the context it is used in.
Idioms, however, make no sense when you take them literally. You have to learn the meaning of an idiom the way you learn the meaning of an unusual or foreign word.
So understanding the picture a metaphor paints is much easier than figuring out the meaning of an unknown idiom.
Another difference is that you can make up new metaphors quite easily. Novelists and creative writers in particular try to put the pictures in their heads into words with the most fitting or expressive metaphor they can find or invent.
You cannot simply make up a new idiom, though, because many people have to share its meaning before the phrase makes sense.