Straight from the Mame License.
G06. Is MAME illegal?
No. Emulating another platform, in itself, is NOT illegal. It is NOT illegal to have MAME on your computer, on your website, or to give it to friends.
ROM images are a different matter. Many ROM sites have been politely contacted by ROM copyright-owners and asked to take images offline. At the time of this writing, however, no site has been LEGALLY shut down, or prosecuted.
There are a few clear precedents about ROMs' legality: Capcom has licensed some of its classic ROMs to be bundled with Hanaho's HotRod Joystick control panel. By buying one, you can have some absolutely legal ROMs. There is also now a service which sells licenses to possess and use ROMs, called StarROMs. They offer a legal way to have ROMs for some of the games supported by MAME, and hopefully more services like this will appear in the future.
Possessing ROM images of circuit boards you do not own may constitute a copyright violation, much like copying a friend's game or audio CD rather than buying it. This is still a legal gray area; possession of such ROMs will not necessarily lead to legal prosecution. In any case, you are responsible for your own actions. No one connected with the MAME project is responsible if you get in trouble.