I'm an Ubuntu 13.04 user and I'm trying to run a script at startup. I created it in /etc/init.d/, gave it chmod 755 and ran the update-rc.d <your script> defaults command. The script is remapping my mouse's keybindings and contains the following:

#! /bin/sh
xinput set-button-map 10 1 2 3 4 5 6 7 9 8

It runs correctly if I do it manually, but I want it to run with startup.

If you add scripts to the rc.d it will start before the Xserver or xorg is up, also it will apply from the root user perspective. The most preferable place to do this is /etc/X11/xinit/xinput.d/ for system wide X start up scripts or ~/.xinputrc for users based ones.

For this you should install im-config (it should be the default in Ubuntu) and add your script in that folder or file.