He spoke to the Duke and Duchess of Sussex at the European Premiere of the new Lion King film on Sunday night.
Williams, best known for writing and singing the hit 'Happy', told the couple that their biracial and transatlantic relationship was 'so beautiful'.
The conversation between Harry and Meghan and the US singer-songwriter was picked up by one of the accredited television cameras at the event in London's Leicester Square.
After referring to the Prince as 'bro', the group then laughed about the musician's outfit - he was wearing shorts with his tuxedo and bow tie.
Williams then said: "It's so beautiful, your union. Love is amazing. It’s beautiful. Don’t ever take that for granted, what it means in today’s climate. I wanted to tell you, it’s so significant for so many of us. Seriously. It's significant. We cheer you guys on."
Both the Duke and Duchess looked touched by his words and Meghan replied: "Thank you."
Meghan is of mixed heritage. Her mother is an African-American born in Ohio. Her father is white.
The couple chose Reverend Michael Curry to give a sermon at the ceremony and they also asked the Kingdom Choir gospel singers to perform.
In America, the issue of race remains one of the country's deepest wounds - as most recently shown by the reaction to President Trump's attacks on some Democrat congresswomen which have been branded 'racist'.
There have also been accusations that some sections of the British press and social media have treated Meghan unfairly because of her heritage.
It seems Pharrell Williams wanted to remind Harry and Meghan about the significance of what they had done and the message they had sent to America and the world.
The Duchess of Sussex was then heard telling Williams: "They don't make it easy'.
It's not clear what Meghan was referring to as being not being 'easy', whether that was the press reaction or a wider reaction to their marriage in society.
Meghan has spoken before of the difficulty she encountered as an biracial actress being cast for roles in television and film.
But after she said those words, Williams asked her: "So you understand the significance? It's beautiful".
Pharrell Williams has produced a number of music tracks in the Lion King film.