As described in https://wiki.ubuntu.com/X/Config/Input, this can be achieved via the hal policy configuration in ubuntu 8.10 -- 9.10. All .fdi files in /etc/hal/fdi/policy will affect the device being plugged in, if the specific match succeeds.
Current properties of a device can be checked via lshal | less. A mouse device will most likely contain a line like:
info.capabilities = {'input', 'input.mouse'} (string list)
In order to remove the 3rd button emulation, the following content has to be saved as an .fdi file in the policies folder:
<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="info.capabilities" contains="input.mouse">
<merge key="input.x11_options.Emulate3Buttons" type="string">no</merge>
</match>
</device>
</deviceinfo>
Although the wiki lists other changes as well (like setting the driver to "mouse"), it does not always work and may cause xorg crash or hang completely. This is the minimal file needed to only disable the button emulation. The option will be changed after the device is plugged in again.