Let F be a totally real field, p an unramified place of F dividing p and r : Gal(F /F ) → GL 2 (Fp) a continuous irreducible modular representation. The work of Buzzard, Diamond and Jarvis [9] associates to r an admissible smooth representation of GL 2 (Fp) on the mod p cohomology of Shimura curves attached to indefinite division algebras which split at p. When r| Gal(Fp/Fp) is tamely ramified and generic (and under some additional technical assumptions), we determine the subspace of invariants of this representation under the principal congruence subgroup of level p. In particular, the subspace depends only on r| Gal(Fp/Fp) and satisfies a multiplicity one property.Theorem 1.1. Assume that F v is unramified over Q p and ρ is tamely ramified and generic. Under certain assumptions (see Cor. 3.9), we have πRemark 1.2. After the first version of the paper was written, we are informed that Le, Morra and Schraen obtain a similar result independently [19]. Both the proofs use results of [13] as a global input, however, the local representation theory part is quite different.We also prove a similar result when D is a definite quaternion algebra unramified at all places over p. In [13], the subspace of pro-p-Iwahori fixed vectors of π D v (r) is determined, for ρ generic, but could be reducible non-split. The proof of our theorem uses the construction of [13] as a main tool. We intend to extend the result to reducible non-split ρ in future work.The organization of the paper is as follows. In Section 2, we give all the local results that we need, especially the local criterion Corollary 2.29. Note that the criterion does not apply to ρ reducible non-split (see Remark 2.27). In Section 3, we deduce our main theorem from our local results and results of [13].