The tram typically adopts the form of semi-independent right of way, which is affected by the traffic light at junctions. The parking and wait time of the tram due to red lights will increase the energy consumption and reduce the passenger comfort. This paper proposes a speed trajectory optimization approach for the tram without parking when encountering a red light. This approach is realized by reasonably adjusting the running time and speed of the tram between two adjacent sections bounded by the traffic light at the junction, on the premise that the total travel time of the whole section remains unchanged. In the model, the constraints of tram movement, speed limits, and line conditions are considered. Moreover, considering the influence of the traffic light, the comfort and traffic light constraints are added to establish the energy-efficient tram speed trajectory optimization model. The nonlinear constraints in the optimization model are converted to linear constraints using the segmental approximation method and adding constraints. As a result, the optimization model is reformulated into a mixed-integer linear programming model, which could be solved by a commercial solver like CPLEX. Numerical experiments are conducted with a 3,660 m long section of the tram line with the traffic light at the junction. The experimental results show that the speed trajectory optimization approach considering the influence of the traffic light proposed in this paper can reduce the total energy consumption by 23.46% and improve passenger comfort.