Where do big countries borrow money from?

I read in news all the time that all countries have huge debts, even the biggest economies of the world have trillions of dollars of debt. If everyone owes money, then who lends money to whom? Where do these countries borrow money from?