The 31-year-old was on loan at Brazilian side Gremio from Juventus on a deal that was supposed to last until this summer when his contract with the Old Lady would have expired.
But Gremio have been relegated from the top tier of Brazilian football and Costa will now spend the rest of his Juventus contract at Galaxy before joining them permanently this summer until 2023.
Costa made 28 appearances for Gremio and scored three goals last season.
“Douglas is a world-class player and a proven champion at the highest level. His capacity to create and finish will add yet another level to our attack,” said LA Galaxy head coach Greg Vanney.
“We are excited to integrate him into the team as we push toward the start of the season.”
In a video announcing his arrival, Costa said: "I have earned many titles and trophies. I could have gone anywhere, but I chose the Galaxy. I'll bring the flash that LA expects. Are you ready?"
Costa won three Serie A titles with Juventus and three Bundesliga titles with Bayern Munich.
The former Shakhtar Donetsk star has featured 31 times for the Brazil national team, scoring three goals.