Check out the IAB (Interactive Advertising Bureau)
They have specs on some commonly agreed-upon things like ad-banner formats. They seem to deal mostly in business issues and less on the technical/implementation specifics.
The simplest implementation is simply pointing to an image from another server. That server will identify on which site the advertisement is being displayed (from the 'Referer' header, or from an id or token passed with the image request). Then the image is returned and the pageview is recorded. If the viewer clicks on the add, a link also pointing back to the ad server will record a 'clickthrough' and then forward the request on to the advertiser.
The database might look like this (drasticly oversimplified, for example only):
Pages
+---------+----------------+
| page_id | name |
+---------+----------------+
| 1 | mycoolsite.com |
+---------+----------------+
Advertisements
+-----------------+------------------+--------------------------------+
|advertisement_id | image_name | target_url |
+-----------------+------------------+--------------------------------+
| 1 | banner1_468.png | http://new-amazing-product.com |
+-----------------+------------------+--------------------------------+
Actvity
+--------------+--------------------+--------+--------+
| page_id | advertisement_id | views | clicks |
+--------------+--------------------+--------+--------+
| 1 | 1 | 0 | 0 |
+--------------+--------------------+--------+--------+
In the page which will display the add you'd put this in the html:
<iframe src="http://your-ad-server.com/ads/image?site=1" />
When a user viewed the page, the request for the image would go to the ad-server. The ad-server would look up the request, select an advertisement to show (many proprietary algorithms here), record the request, and finally return the response.
Actvity
+--------------+--------------------+--------+--------+
| page_id | advertisement_id | views | clicks |
+--------------+--------------------+--------+--------+
| 1 | 1 | * 1 * | 0 |
+--------------+--------------------+--------+--------+
The response could contain the following (retreived from the database):
<a href="http://your-ad-server.com/ads/click?id=1">
<img src="http://your-ad-server.com/ads/banner1_468.png" />
</a>
Now the image is loaded and shown on the page. If the user decides to click on it, again the request goes to the ad server which records the click and finally redirects the request to the page being advertised.
GET /ads/click?id=1
301 Moved Permanently
Location: http://mycoolsite.com
Actvity
+--------------+--------------------+--------+--------+
| page_id | advertisement_id | views | clicks |
+--------------+--------------------+--------+--------+
| 1 | 1 | 1 | * 1 * |
+--------------+--------------------+--------+--------+