The browser asks your machine/device if it knows the IP address of the website you are looking for. If it does, it returns the IP address to your browser, if it doesn’t it asks the machine your machine/device is connected to. (That may be another machine in your office/home or it may be a machine at your Internet Service Provider (ISP)
The connected machine then repeats the question, if it knows the answer it returns the answer, if not it asks the machine it in turn is connected to.
This process is repeated right back to the “root servers” which return an authoritative answer for each of the TLDs (.com’s .info’s etc.). The root server would then send the asking machine to VeriSign’s servers for a .com or Afilias’s severs for .info domain.
Each of those companies maintain an authoritative list of IP addresses for all their customers’ second level domains. (yourdomain.com, mydomain.com, webmasterworld.com etc.)
If the owner of the second level domain you are looking for has configured third level (‘sub’) domains on his domain (www.yourdomain.com, ftp.yourdomain.com, sales.yourdomain.com) the IP of those addresses will be returned by a DNS server maintained by the second level domain owner.
Once a machine in the chain has done a look up it hangs on to the answer for a while in case it's asked again, that way it knows the answer without having to ask again which means it can return the answer quicker. The only problem is site some owners may change/reconfigure IP addresses of their domains so it can only risk hanging on to the answer for a little while.