Afterslip and viscoelastic relaxation are two important mechanisms that can explain observed postseismic deformation. For large megathrust events, such as the 2011 Mw=9.0 Tohoku earthquake, it is likely that these two processes happen simultaneously. While coseismic stress change triggers large amounts of flow in the viscous layers below the rupture, afterslip on the fault continues to stress the Earth and causes more viscoelastic relaxation. In other words, afterslip and viscoelastic relaxation are fully coupled. Conventional inversion considers afterslip separately from viscoelastic relaxation. Researchers either assume all the postseismic offsets are caused by afterslip (ignoring viscoelastic relaxation) or they only consider viscoelastic relaxation caused by coseismic change. The viscous flow induced by afterslip is usually ignored. For smaller earthquakes, these strategies may be reasonable, but for huge megathrust events like Tohoku, this can cause a misinterpretation of the data as a consequence of neglecting the coupling effects between afterslip and viscoelastic relaxation. In this work, we develop a strategy to invert GPS data for afterslip within a viscous Earth media considering the concurrence of afterslip and viscoelastic relaxation. The position time series predicted by an Earth model containing viscous layers of linear Maxwell rheology are proportional to the magnitude of the source. If we treat the source as input and Earth's deformation as output, this structure forms a linear time invariant system. In such systems, we can use outputs to linearly invert for inputs, i.e., use observed time series to invert for slip history on the fault embedded in a viscously flowing media. We implement this inversion scheme using three years of GPS position time series data from GEONET of Japan following the Tohoku earthquake. We use a grid search to estimate the elastic depth of the Earth and the viscosity of the lower crust and upper mantle. Based on the presented mathematical formulation, the deformation in the postseismic phase is due to the concurrence of three components: elastic deformation caused by afterslip, viscous flow of the surrounding Earth media induced by coseismic slip and viscous flow induced by afterslip. Our inversion results using postseismic data of the Tohoku earthquake show how much each of these three components contributes to the overall postseismic deformation. This demonstrates that it is important to account for the viscous rheology of the Earth when inverting for afterslip following large megathrust earthquakes.