The 20-year-old, who signed a new two-year deal with Birmingham in May, will stay at Oakwell until November 1.
“I am really pleased to join the club for what is sure to be an exciting season ahead,” Townsend told Barnsley’s official website.
“Since I heard of the interest, I’ve tracked the players coming into the club and I’ve been very impressed with the quality of the players recruited.
“I know the goalkeeper coach, John Vaughan, and after speaking with (head coach) Lee Johnson, I can’t wait to get cracking.
“This is a remarkable opportunity for me to progress at a big club in a very competitive league.
“They’re a hungry and talented squad and I’m really looking forward to pushing Adam Davies as far as possible during my time here.”
Townsend progressed through Birmingham’s academy but is yet to make a first-team appearance for the club.
He has had two previous loan spells at Lincoln, where he made a total of 31 appearances for the Conference club.