It depends on the broker.

By way of instance, if you exchange on LMAX, you do not contrary to the broker, but directly with other people or associations, for example with banks or even Hedge funds.

Yet there are other Brokers, which of course I don't name for fairness reasons, which trade directly with or contrary to the client. So your profit is their loss and vice versa. They basically say hello client, I'm gonna wager that you lose money that's actually true in many cases since just few traders are profitable on the long term. So this notion can be really rewarding for a broker because most people lose money in the forex market.