Pakistan has threatened to quit a Saudi-led military coalition if it were to be used against any Muslim country including Iran.