This paper builds a task-based, imperfectly competitive labor market model and estimates it using linked employer-employee data from Brazil. The model matches several measures of wage inequality and generates realistic firm-worker sorting patterns, firm wage premiums, and minimum wage spillovers. I decompose changes in wages and sorting into contributions of education, technology, minimum wage, and other shocks. The minimum wage is the main driver of falling inequality while rising assortativeness is due to skill-biased technical change. I also show that firm heterogeneity and imperfect competition can qualitatively alter the effect of supply, demand, and institutional shocks on the wage distribution.