Let π(f) be a nearly ordinary automorphic representation of the multiplicative group of an indefinite quaternion algebra B over a totally real field F with associated Galois representation ρf. Let K be a totally complex quadratic extension of F embedding in B. Using families of CM points on towers of Shimura curves attached to B and K, we construct an Euler system for ρf. We prove that it extends to p-adic families of Galois representations coming from Hida theory and dihedral ℤdp-extensions. When this Euler system is non-trivial, we prove divisibilities of characteristic ideals for the main conjecture in dihedral and modular Iwasawa theory.