The Gallagher Premiership club said the 31-year-old will be joining them with immediate effect.
Webb, who will rejoin the Ospreys next term, could feature in next Sunday's Premiership west country derby against Bristol.
French club Toulon had agreed to release Webb from the final year of his contract with them so he could link up again with the Ospreys.
Toulon then announced his immediate departure last month, but Webb's only appearance of late was as a replacement during Wales' opening Guinness Six Nations game against Italy on February 1.
Although he falls short of the minimum 60-cap requirement for players plying their trade outside of Wales to be available for Test rugby, the Welsh game's Professional Rugby Board granted him a six-month dispensation, which made him available for this season's Six Nations.
Webb has won 32 caps and toured with the 2017 British and Irish Lions to New Zealand.
He was on the Wales bench against Italy but did not feature in head coach Wayne Pivac's match-day 23 for Six Nations appointments with Ireland and France.
"We're very excited to be bringing in an international talent to join the group, and to add some depth and quality to our scrum-half position at such a critical time of the year," Bath rugby director Stuart Hooper told the club's official website.
"Obviously, there will be some familiar faces for him here, and a signing of this calibre is something I know will be welcomed by the squad.
"I am sure he will settle in quickly, and I know he is looking for some game-time as soon as possible."
Bath are currently one point adrift of the Premiership play-off zone heading into their game against third-placed Bristol at the Recreation Ground.