Sharon Osbourne went to bed with comedian Robin Williams — and the tryst was arranged by Ozzy himself!

“I snuggled between the sheets with Robin Williams. And it was Ozzy who was responsible for us being in bed in the first place!” Sharon told The ENQUIRER in an exclusive interview.

But it’s not what you think. Williams gave Sharon lots of yuks, but no hanky-panky.

“I’d always liked Robin Williams,” Sharon says. “I love his sense of humor, he always made me and Ozzy laugh whenever we watched him in a movie or on TV. But I’d never met him before in my life — even though I’d always wanted to.”

When Sharon was given the devastating news last summer that she had colon cancer, Ozzy had the idea that laughter was the best medicine for his beloved spouse.

“He was watching a movie of Robin’s called ‘Patch Adams’ about a doctor who used to dress in funny outfits, like a clown, and crack his patients up,” said Sharon. “And my husband thought that he could do that for me!”

So, Ozzy called Robin up and asked him to come by the house and surprise Sharon . . . and he agreed.

“Robin was just the nicest, most giving guy,” Sharon says. “He came around to the house. I was in bed when he came by, half asleep and a little woozy from some of the medication the doctors had given me to take.

“Suddenly, there’s a knock on my bedroom door and I say, ‘Come in.’ And there’s Robin Williams standing in front of me!

“Well, I thought I must be dreaming. In fact, I thought I was hallucinating from the drugs I’d been given!

“I couldn’t think of what to say, so I said, ‘Does Ozzy know you’re here?’

“Then, Robin got in bed with me and said, ‘Shhh! No, he doesn’t and don’t tell him!’

“Well, that just cracked me up. I was in bed with Robin Williams. I started laughing hysterically.

“For the next two hours, he just cuddled me.”

Sharon giggled, “We went through all the lines from all of my favorite films of his. Robin had me in absolute stitches!

“He was just the nicest, most giving guy in the world! He did so much for me.”

Sharon says that she hasn’t gotten in touch with Robin since their two-hours of “pillow talk” because she’s “too embarrassed” to call him!

“I mean, I don’t want to bother him,” Sharon said. “He came all the way down from where he lives (outside of San Francisco) just to see me.

“I was so overwhelmed. What a heart he has!”

And Ozzy will never forget what Robin did to lift Sharon’s spirits that day in bed.

“Forever and a day, I will love that man,” he said.