To create the KML goto maps.google.com and select My Maps and follow these steps:
Click on link create new map (1) and make your own markers, polylines and polygons.
For using a map created by somebody else or a route created by maps.google.com:
Click on link import (2)
Place url in second field and add at the end &oe=UTF8&output=kml (3)
Press button upload (4)
Add or change the map according to your wishes
Don't forget to save the map.
You can find the MSID at maps.google.com by clicking on link.
Copy the value of the parameter MSID in the given url: {mosmap msid='209290366228951928993.0004c05e9829f52a1251b'} and remove the other url parameters and the http:// part.
Linkes generated by google does not work anymore. Google removed the option to generate a kml. No solution yet to easily show a google maps query url in google maps api version 3. So the following example does not work anymore: