Yes. The situation is analogous to borrowing money to invest in the stock market: Your profit is the profit you make from the stocks minus the interest you pay on the loan, and that difference is what you pay tax on.
In Canada, a mortgage on a principle residence is not tax deductible, since Canadian tax law doesn't consider where you live to be an "investment"; this is balanced by a principle residence being exempt from capital gains tax.