Legends say that Prince Shōtoku Taishi 聖徳太子 (574-622) sent a letter to the Chinese Emperor, where he calls himself by the title "emperor of where the Sun rises" (日出處天子). From approximately this period, China began to call Japan "日本國", and no more 倭國 (jap. wakoku, chi. woguo as before).
In 7th Century Chinese 日本 was pronounced *nit-pon ( ripen in modern standard Chinese), which became nippon in Japanese.
In Chinese, we have the following phonetic evolution (@=neutral vowel, sounds like "uh" in English, r=retroflex fricative, which sounds approximately like "gee") :
*nit pon kw@k > *rit pon kw@k > *ri p@n kwo
This sounded like "gee-puhn-kwo" to the ears of early explorers, and gave birth to the names "Jipango", "Zipanguo", etc.
"Japan" is clearly derivated from this Chinese pronouciation, but from which Chinese dialect (or other Asian language) it was borrowed is still unclear.
By the way, the original Japanese word for "Japan" is Yamato.