The 30-year-old Scot has become Nicky Forster's first signing since he took over as caretaker manager at Griffin Park.
"Robbie is a flexible player who can play as a right-sided centre-back or a right-back and is comfortable in either role," said Forster.
"He's a seasoned professional and has played games at Championship level.
"He is looking forward to coming here to play regular first-team football."
Neilson will be in line to make his debut when the Bees are next in action against Tranmere on Tuesday.