Louis Tomlinson Custody War Settled I Get the Baby ... For a Price

2/26/2016 10:32 AM PST BY TMZ STAFF

0226-tomlinson-jungwirth-getty-akm-01Louis Tomlinson and Briana Jungwirth have reached a shaky temporary settlement in their custody war ... avoiding a courtroom showdown by a matter of hours.

We've learned lawyers for the One Direction singer were going to court Friday morning armed with legal docs and their famous client, asking a judge to formally establish paternity on Louis' part and give him access to his 1-month-old son, Freddie.

TMZ broke the story ... Briana was not giving Louis access to their kid and the dispute was over money. We're told under the temporary settlement, he will have access to the child for several hours at a time during the week, but he will not have any overnight visits.

We're told until a short time ago, Louis was paying Briana's expenses but there was no set amount -- it varied from week to week. Things went south when they tried to establish a set monthly amount ... she wanted way more than he was willing to give.

Our sources say the 2 parents have agreed to a temporary custody arrangement while their lawyers hammer out something formal ... both with custody and child support.