This is a well-known problem, and as far as I know there is no easy answer.
The general problem is called QoS, short for Quality of Service. At the level of the networking infrastructure, what you can do is traffic shaping.
There is a fundamental limitation of traffic shaping for your use case (which is a very common one): you need to act at the point of entry to the bottleneck, not at the point of exit. But typically the bottleneck is the connection between your home/workplace to your ISP's infrastructure, and you can't control what happens at your ISP's, so you can only shape upload, not download. This means you can effectively prioritize web browsing over bittorrent, but not (say) streaming content over background downloads.
If you have a home router and it supports QoS/shaping/whatever-it-calls-it, its interface is likely to be easier to use than what Ubuntu can offer. So look there first. But this is an advanced feature not found in all routers.
Most bittorrent clients should be able to limit bandwidth usage. If you have less upload than download bandwidth (which is typical for home users over DSL), setting the limit to 70%–80% of your bandwidth should leave room for comfortable web browsing.