I will try to keep the long story short, but (in case someone needs) full description can be found in Selenium 2 Testing Tools by David Burns.
WebDriver tries to control the browser from outside the browser. It uses accessibility API to drive the browser. The accessibility API is used by a number of applications for accessing and controlling applications when they are used by disabled users and is common to web browsers. WebDriver uses the most appropriate way to access the accessibility API. If we look at Firefox, it uses JavaScript to access the API. If we look at Internet Explorer, it uses C++. This approach means we can control browsers in the best possible way but has the downside that new browsers entering the market will not be supported straight away.
The system is made up of four different sections:

So after the API code enters the SPI (Stateless Programming Interface) and it is then called to a mechanism that breaks down what the element is, by using a unique ID, and then calling a command that is relevant.
do Webdriver use REST api?
From there we call the JSON Wire protocol. We still use HTTP as the main transport mechanism. We communicate to the browsers and have a simple client server transport architecture that is able to transport all the necessary elements to the code that controls it. It uses a REST like API as the way to communicate.
Last section is the Selenium server, or browser, depending on what is processing, uses the JSON Wire commands to break down the JSON object and then does what it needs to. This part of the code is dependent on which browser it is running on. As mentioned above, it could be done in the browser via C++; if it's in IE or if not available we inject Selenium.