James D. Ricks, a Ballou High School chemistry teacher, edged out 19-year incumbent William H. Simons yesterday for the presidency of the D.C. Teacher's Union.

Simons has been president of the union that represents the school system's 5,500 teachers since its founding in 1964. Ricks, who had run against Simons on three previous occasions, won with 1,146 votes to 1,142 for Simons in a four-way race.

Simons was surprised but magnanimous in defeat last night. "That's the way the ball bounces," Simons said, adding that he did not know whether he would request a recount.

"I felt confident about the way things were going," Simons said. "I had gotten no massive complaints from teachers. All I can say is that I'm grateful for having served for 19 years."

Simons had won another two-year term last spring, easily defeating Ricks 553 to 338. However, Ricks claimed that the election had not been conducted properly and asked the U.S. Labor Department to seek to overturn the election in court.

Last November U.S. District Court Judge Aubrey E. Robinson Jr. ruled that the election was not conducted by secret ballot as required by federal law and ordered a new election. The election was conducted by a mail ballot and Labor Department observers watched yesterday's ballot tabulations.

Ricks was not available for comment immediately after the results were announced last night. Jeanette Feely was Ricks' running mate and defeated Luther C. Shelton, a slate-mate of Simons, 1,129 to 1,108. "This is the culmination of a 10-year struggle. People were ready for a change," she said.

Observers attributed Simons' defeat to the four-way split in the votes and the large turnout. In this election, Simons was challenged by two former supporters, who may have managed to take the deciding votes from Simons.

The turnout in previous elections has been fewer than 1,000. This year's balloting drew 2,582, possibly because mail ballots are easier to cast.