The Irish star, whose first album Flicker topped charts around the world, was contacted by the Rock DJ singer last month about hitting the studio together.
A source told Daily Star Online: “In February Robbie reached out to Niall to see if he wanted to join him in the studio.
“Niall is a big fan of Robbie so he jumped at the chance.
“He is close to Robbie and Ayda as well as Robbie’s mother in law Gwen – she’s is a big fan of Niall, so the team-up just seems natural for Robbie.”
The music insider aded: “The session was more of a casual team up rather than any songs definitely for Niall or Robbie’s next album.”
“It’s not known when the lads will hit the studio, but Robbie is currently in the middle of his Las Vegas residency, meaning he is based Stateside.
Robbie Williams: Live in Las Vegas has already managed to sell out the majority of the dates at Sin City’s Encore Theater at Wynn.
Since leaving One Direction, Niall has worked hard to carve out a successful solo career.
“In February Robbie reached out to Niall to see if he wanted to join him in the studio”
As well as releasing Flicker in 2017, the crooner dropped a live version of the record featuring the RTÉ Concert Orchestra.
Last year he also embarked on a 81-date world tour in support of the record.
Meanwhile, Robbie made the jump into reality TV after finally agreeing to be a judge on The X Factor.
The Take That legend had long been on Simon Cowell’s hit-list, though refused to sign on the dotted line.
However, once making the move – and joined by his wife Ayda – Robbie admitted it was one of the best things he had ever done.
Previously chatting to Daily Star Online, Robbie Williams said: “Honesty, it’s the best thing I have done in showbiz, I’m loving it.
“I’ve done 30 years of album, promo, tour, album, promo, tour and now I have found myself behind a desk judging people and I can understand why people enjoy doing that on Twitter.
“You get a dopamine rush and it is quite addictive.”