Mobile edge computing (MEC) is a promising solution to support emerging delay-sensitive mobile applications. With MEC servers deployed at the network edge, the computational tasks generated by these applications can be offloaded to edge nodes (ENs) and quickly executed there. Meanwhile, with the projected large number of IoT devices, the communication and computational resources allocated to each user can be quite limited, providing low-latency MEC services becomes challenging. In this paper, we investigate the problem of task partitioning and user association in an MEC system, aiming to minimize the average latency of all users. We assume that each task can be partitioned into multiple independent subtasks that can be executed on local devices (e.g., vehicles), MEC servers, and/or cloud servers; each user can be associated with one of the nearby ENs. We formulate a mixed-integer programming problem to determine the task partitioning ratios and user association. Such a problem is solved by decomposing it into two subproblems. The lower-level subproblem relates to task partitioning under a given user association, which can be solved optimally. The higher-level subproblem is user association, where we propose a dual decomposition-based approach to solve it. Simulation results show that, compared to benchmark schemes, the proposed schemes reduce the average latency by approximately 50%.