We prove the one-dimensional almost sure invariance principle with essentially optimal rates for slowly (polynomially) mixing deterministic dynamical systems, such as Pomeau-Manneville intermittent maps, with Hölder continuous observables.Our rates have form o(n γ L(n)), where L(n) is a slowly varying function and γ is determined by the speed of mixing. We strongly improve previous results where the best available rates did not exceed O(n 1/4 ).To break the O(n 1/4 ) barrier, we represent the dynamics as a Young-towerlike Markov chain and adapt the methods of Berkes-Liu-Wu and Cuny-Dedecker-Merlevède on the Komlós-Major-Tusnády approximation for dependent processes. Theorem 1.3. Let γ ∈ (0, 1/2) and ϕ : [0, 1] → R be a Hölder continuous observable with ϕ dµ = 0. For the map (1.1), the random process S n (ϕ) satisfies the ASIP with variance c 2 given by (1.4) and rate o(n γ (log n) γ+ε ) for all ε > 0. For the map (1.5), the random process S n (ϕ) satisfies the ASIP with variance c 2 given by (1.4) and rate o(n γ ).The rates in Theorem 1.3 are optimal in the following sense:Proposition 1.4. Let f be the map (1.1). There exists a Hölder continuous observable ϕ with ϕ dµ = 0 such that lim sup n→∞ (n log n) −γ |S n (ϕ) − W n | > 0 for all Brownian motions (W t ) t≥0 defined on the same (possibly enlarged) probability space as (S n (ϕ)) n≥0 . Hence, one cannot take ε = 0 in Theorem 1.3.Remark 1.5. If c 2 = 0, the rate in the ASIP can be improved to O(1). Indeed, then it is well-known that ϕ is a coboundary in the sense that ϕ = u−u•f with some u : [0, 1] → R. By [7, Prop. 1.4.2], u is bounded, thus S n (ϕ) is bounded uniformly in n.Remark 1.6. It is possible to relax the assumption that ϕ is Hölder continuous. As a simple example, Theorem 1.3 holds if ϕ is Hölder on (0, 1/2) and on (1/2, 1), with a discontinuity at 1/2. See Subsection 4.3 for further extensions.Remark 1.7. Intermittent maps are prototypical examples of nonuniformly expanding dynamical systems, to which our results apply in a general setup, and so does the discussion of rates preceding Theorem 1.3. We focus on the maps (1.1) and (1.5) for simplicity only, and discuss the generalization in Section 5.