UBS has struck a deal with the Swiss government to protect it from billions in potential losses when it acquires Credit Suisse.

The Swiss government will provide UBS with up to CHF9bn ($9.9bn) to shield it from losses after the bank agreed to rescue its Swiss rival in March.

The agreement is one of the final hurdles to the deal, which is expected...