Ghanaian-born Kweku Adoboli, 32, exceeded his trading limits and failed to cover his losses, allegedly faking records to hide his tracks at the bank's London office. At one point, Adoboli risked running losses of up to $12 billion.
"There is a strong streak of the gambler in you," Judge Brian Keith told Adoboli. "You were arrogant to think the bank's rules for traders did not apply to you."
Adoboli wiped away tears as Keith handed down his sentence.
A conviction for fraud carries a maximum jail term of 10 years.
The 10-person jury at Southwark Crown Court in London found Adoboli guilty of two counts of fraud and innocent of four other false accounting charges.
The trader ran into trouble dealing in exchange traded funds, complex financial products that track stocks, bonds and commodities. Adoboli admitted the losses, but said he was pressured by staff to take risks.
He also testified last month that he had been trying to help UBS survive after it amassed losses of $52 billion during the 2007-2008 global financial crisis.
"There were times we thought there was no way the organization would survive," said Adoboli, who joined UBS as a trainee in 2003 and rose quickly to become a senior trader. "I grew up with UBS. I felt very loyal to UBS."
Detective Chief Inspector Perry Stokes of City of London Police, who led the investigation of Adoboli, had a different view, believing the trader's motive was "to increase his bonus, his status, his job prospects and his ego."
"Adoboli was a sophisticated fraudster," Stokes said. "He was one of the most accomplished fraudsters that I've seen in my time investigating serious fraud."
After questions were raised about his trading, Adoboli walked off the job and sent an email to colleagues saying what he had done.
"I take full responsibility for my actions and the s--- storm that will now ensue. I am deeply sorry to have left this mess for everyone and to have put my bank and my colleagues at risk," he wrote.
The conviction on the second fraud count came on a 9-1 vote after the judge said he would accept a majority verdict. The sentences, to be served concurrently, were seven years on the first charge and four years on the second.
"We are glad that the criminal proceedings have reached a conclusion and thank the police and the U.K. authorities for their professional handling of this case," UBS said in a statement. "We have no further comment."
Prosecutors said it was the biggest fraud in British banking history, but it wasn't the largest trading loss. U.S.-based JPMorgan Chase lost at least $5.8 billion through bad trades at its London office, the bank's CEO Jamie Dimon said in July.
Raphael Satter in London contributed to this report.