Voltage causes sparks, but...
Maybe you got the spark when you disconneted the wire.
In that case, you likely have a ground loop carrying
current and a long wire.
When you disconnect the wire, the current wants
to keep flowing due to loop inductance.
This causes the voltage spike and hence the spark.