@kimrichards11 / Instagram 1 / 7
@kimrichards11 / Instagram 1 / 7

Monty Brinson, ex-husband of "Real Housewives of Beverly Hills" star Kim Richards, died Sunday after a long battle with lung cancer. He was 58.

A source close to Brinson confirmed to ET that he passed away in a medical facility, surrounded by his family.

While Brinson had been fighting his illness for a long time, the source tells ET he seemed to be improving just days ago.

WATCH: Kim Richards Is Staying by Ex-Husband Monty Brinson's Side as His Cancer Battle Comes 'to an End'

"It was important to him to be an inspiration to others fighting cancer, he was fighting til the end," the source said. "We are all in a fog. It doesn't seem real yet."

Brinson and Richards were married for three years, from 1985 to 1989, and welcomed their daughter, Brooke, in 1989. After their divorce, the former couple remained close friends.

Richards reportedly spent a lot of time with Brinson in his final weeks, gathered with his family around his hospital bed at an assisted living facility.

RELATED: Kim Richards and Monty Brinson's Daughter Shares Touching Photo of Father-Daughter Dance

Brinson appeared to be at peace with his terminal illness, according to Instagram posts he shared in the weeks prior to his death.

"I'm surrounded by love," Brinson wrote in a caption to a post shared earlier this month. "I got plenty of love in my heart. I'm here for everybody. This might be my final resting place but I'm content."