Marcelo, 17, will join the English champions in for €2m (£1.8m) including performance-related bonuses.
Fluminense will also insert a 25% sell-on clause, entitling them to further profit if Liverpool sell Marcelo.
Because he has a German passport, Marcelo will be able to join Liverpool right away, rather than wait for his 18th birthday.
Marcelo’s transfer to Liverpool will be complete once bureaucratic procedures and contractual arrangements are sorted.
Fluminense did not want to negotiate the teenager’s sale, but financial difficulties gave them no choice.
Negotiations intensified in recent days for Marcelo, who is under contract with Flu until 2022.
The Brazilian youth international and his family have always wanted a move to Europe and will now get the chance.
Liverpool’s plan is to make him the long-term heir to his compatriot, Alisson, who Marcelo has already spoken to.
Despite the considerably low fee, Marcelo will reportedly be the second biggest sale of a goalkeeper in Brazilian football history.
That record is held by Alisson himself, who joined Roma from Internacional in 2016 for €8m.
Alisson went on to sign for Liverpool in what was, for four weeks, a world record fee of €72.5m.