The bank admitted it had wrongly collected millions of dollars in fees, misused customer information and harmed the credit rating of customers.
The settlement comes about four years after the scandal first erupted.
It has already forced out two chief executives and led to hefty fines.
Since 2018, Wells Fargo has been operating under an order from the US Federal Reserve that limits its growth.
Last month, former chief executive John Stumpf agreed to pay $17.5m to settle charges, in a rare example of a bank executive being personally punished for failing to stop misconduct.
Charlie Scharf, who became chief executive in October, said the settlement was a “significant step in bringing this chapter to a close”.
“There’s still more work we must do to rebuild the trust we lost,” he added.
“The conduct at the core of today’s settlements – and the past culture that gave rise to it – are reprehensible and wholly inconsistent with the values on which Wells Fargo was built,” he said.
The settlement concerns activities between 2002 and 2016, when the bank’s intense focus on growth put pressure on staff to meet “onerous sales goals”.
The environment ultimately led workers to create fake accounts, sell services that customers did not need, and shift money between accounts, among other illicit activities, prosecutors said.
Top managers of Wells Fargo’s consumer division were aware of the “gaming practices” as early as 2002, they said. In 2004, an internal investigator called it a “growing plague”, according to the settlement.
“This case illustrates a complete failure of leadership at multiple levels within the bank. Simply put, Wells Fargo traded its hard-earned reputation for short-term profits, and harmed untold numbers of customers along the way,” US Attorney Nick Hanna said.
“We are hopeful that this $3bn penalty, along with the personnel and structural changes at the bank, will ensure that such conduct will not reoccur.”
Of the $3bn, about $500m is set to be returned to investors who were misled by bank disclosures.
The US Department of Justice said the bank would be monitored for three years for compliance, under a deferred prosecution agreement.
If the bank abides by the conditions of the settlement, including ongoing cooperation in investigations, the charges will be dismissed.