Modern trams usually own passive transit signal priority (TSP) to avoid interruption from traffic signals along the route. The key to TSP depends on the stick to the recommended travel time between intersections strictly. However, the effectiveness of the TSP can be weakened by dwell time fluctuation due to uncertain passenger demand at the stations. This paper proposes a two-stage stochastic optimization model for timetable and tram control to improve the TSP reliability considering uncertain dwell times. The first stage of the model focuses on designing timetable alternatives, and the second stage evaluates the timetables through expected travel time and energy consumption under different dwell time disturbance scenarios. The Brute force algorithm is developed to attain the optimal tram control, while the non-dominated sorting genetic algorithm II (NSGA-II) and GUROBI solver are both adopted to optimize the timetables. A case study of Nanjing Tram Line 1 in China is performed to demonstrate the effectiveness of the proposed approach. The results show that compared to the existing method, the proposed method reduces energy consumption by 16.0% and the number of stops at intersections decreases by 73.7% with the same travel time.