First we need to know that a domain registrar is not the same as a hosting provider, but you CAN typically get your domain name at the same place you buy your hosting from (but you don’t have to).
There are three different roles involved in the domain name registration: the registry, the registrar, and the registrant — that’s you!
A domain name registry is an organization that manages the domain names. They work with registrars to sell domain names to the public. In short, the registry maintains the database. The registrar is an (ICANN) accredited organization that sells domain names to the public: to registrants like you!
You can think of a registrar like a car dealership, and the domain registry is the factory.
Interesting fact: when you “buy” a domain, you are technically just leasing it for a certain period of time. You don’t actually “own” the domain, the registry does.