Kweku Adoboli, 32, traded beyond his permitted limits at the bank's offices in London because he was trying to earn a bigger bonus and wanted to boost his ego, a prosecution lawyer told the court.
Adoboli thought he had the "magic touch" but his actions rocked UBS, lawyer Sasha Wass told the 12-person jury as she outlined the case against the Ghanaian-born son of a former United Nations official.
"He is on trial because he lost his bank 2.3 billion US dollars. He fraudulently gambled it away. He also in doing so wiped around 10 percent or about 4.5 billion US dollars off the bank's share price," Wass said.
"He did all of this by exceeding his trading limits, by inventing fictitious deals to conceal this and then he lied to his bosses.
"Mr Adoboli's motive for this behaviour was to increase his bonus, his status within the bank, his job prospects and of course his ego.
"Like most gamblers, he believed he had the magic touch. Like most gamblers, when he lost, he caused chaos and disaster to himself and all of those around him."
Adoboli denies two charges of fraud and two charges of false accounting relating to a period between October 2008 and September last year.
The court heard he sent an email admitting to trying to hide his mammoth losses, but by the time he was arrested the next day the bank's share price had dived.
UBS, Switzerland's largest bank, is not represented in the trial, but is bracing itself for potentially awkward revelations about its supervision of staff.
The jury was told that the trader managed to hoodwink the bank due to the "extensive knowledge" of its systems gained during his time working in the back office.
Adoboli graduated to the front office, where the trading team operates, in 2005, before moving up to the exchange traded funds desk in 2006.
This desk deals in securities which track certain market indices and are traded like ordinary shares.
He fooled the bank's double entry accounting system, in which each entry is balanced by an equal entry elsewhere in the records, by inventing fictitious deals, the jury heard.
Traders mitigate risk during a transaction by carrying out a similar deal in the opposite direction, hedging any unfavourable market fluctuations.
According to the prosecutor, Adoboli faked hedge deals by inventing clients, leaving the bank exposed to huge absolute losses when the market turned against him.
Despite the colossal losses, UBS's chief executive at the time, Oswald Grübel, refused to step down.
The bank's honorary chairman Nikolaus Senn, however, said that adequate checks had not been implemented and criticized Grübel for his over-reliance on the controls system to uncover problems.
Grübel eventually left UBS. His replacement, Sergio Ermotti, admitted in a statement to staff this month that the case would be "uncomfortable" for the bank.