Mr Musk’s comments came after the Wall Street Journal reported that his friendship with Mr Brin had ended over the alleged affair.
Replying to a link to the story posted on Twitter, Mr Musk referred to the report as “total bs”.
Mr Musk went on to say that he is still friends with Mr Brin and that they were “at a party together last night!”
Citing people familiar with the matter, the Wall Street Journal said that Mr Musk was engaged in a brief affair late last year with Ms Shanahan.
This prompted Mr Brin to file for divorce earlier this year, ending the long friendship between the two high-profile technology billionaires, the paper also said.
But Mr Musk tweeted “I’ve only seen Nicole twice in three years, both times with many other people around. Nothing romantic”.
At the time of the alleged affair in December, Mr Brin and his wife were separated but still living together, the Wall Street Journal said, citing a person close to Ms Shanahan.
In a separate tweet, Mr Musk said “WSJ [Wall Street Journal] has run so many bs hit pieces on me and Tesla I’ve lost count.”
Even though they have a prenuptial agreement, Mr Brin and Ms Shanahan are currently negotiating a divorce settlement, which could be as much as $1bn (£830m), the paper said.
Ms Shanahan is a California-based attorney and founder of legal technology company ClearAccessIP and the Bia-Echo Foundation, according to her LinkedIn profile.
The Bia-Echo Foundation is a philanthropic organisation that promotes “reproductive longevity & equality, criminal justice reform and a healthy & livable planet”.
Mr Musk, who is also the boss of rocket firm SpaceX, is currently embroiled in a legal fight over his abandoned plan to buy Twitter for $44bn.
Earlier this month, the social media platform sued him after he announced he was walking away from his proposed takeover of the firm.
Mr Musk is the world’s richest person, with an estimated fortune of more $240bn, according to the Bloomberg Billionaires Index.
According to the same index, Mr Brin is worth around $95bn, making him the the eighth richest person in the world.