While I have no source for this, I had always assumed it was based on Pirkei d’Rebbi Eliezer ch. 16:
החתן דומה למלך מה המלך הכל מקלסין אותו שבעת ימי המשתה כך חתן הכל מקלסין אותו שבעת ימי המשתה מה המלך לובש בגדי כבוד כך החתן לובש בגדי כבוד מה המלך שמחה ומשתה לפניו כל הימים כך החתן שמחה ומשתה לפניו כל שבעת ימים מה המלך אינו יוצא לשוק לבדו כך החתן אינו יוצא לשוק לבדו מה המלך פניו מאירות כאור החמה כך חתן פניו מאירות כאור החמה שנ' והוא כחתן יוצא מחופתו:
The groom is like a king. Just as a king is praised by everybody during seven days of feasting, so is the groom praised by everybody during seven days of feasting. Just as a king is dressed in garments of glory, so the bridegroom is dressed in garments of glory. Just as a king is rejoicing, with feasts in his presence, all his days, so the groom is rejoicing and has feasts before him all the seven days of the banquet. Just as the king does not go into the market-place alone, likewise the groom does not go into the market-place alone. Just as the face of a king is shining like the light of a sun, so the face of the bridegroom is shining like the light of a sun, as it is said, "And he is as a bridegroom coming out of his chamber, and rejoicing to run his course.”
As we see that a groom is compared to a king, we sing at the wedding, “And there was in Yeshurun a king with the gathering of the heads of the people.”