We propose a framework to identify and estimate earnings distributions and worker composition on matched panel data, allowing for two-sided worker-firm unobserved heterogeneity. We introduce two models: a static model that allows for nonlinear interactions between workers and firms, and a dynamic model that allows in addition for Markovian earnings dynamics and endogenous mobility. We establish identification in short panels, and develop tractable two-step estimators where firms are classified into heterogeneous classes in a first step. Applying our method to Swedish administrative data, we find that log-earnings are approximately additive in worker and firm heterogeneity, with a strong association between workers and firms, and a small relative contribution of firm heterogeneity to earnings dispersion. In addition, we document that wages have a direct effect on mobility, and that, beyond their dependence on the current firm, earnings after a job move also depend on the past firm.