Khoury won with 39,534 votes, against Gemayel's 39,116 votes. Turnout was 46 per cent.
In Beirut, the vote for Walid Eido's seat was easily won by Mohammed al-Amin Itani, a candidate of parliament majority leader Saad Hariri's Future Movement.
The Hezbollah-led opposition did not officially sponsor a candidate and turnout was just 19 per cent.
Although Sunday's vote was for just two seats, the results were seen as a crucial showdown between the pro-US government and the opposition allegedly as legislators are due to elect a new president soon.
It was also seen as a popularity test for Gemayel, president from 1982-1988 and the head of one of Lebanon's most powerful Christian families, and Aoun, a former army commander and interim prime minister allied with the Hezbollah-led opposition.
The vote was to replace the murdered Walid
Eido, left, and Pierre Gemayel [AFP]
Both are Maronite Catholics, as Lebanon's president is traditionally a Maronite Christian who is chosen by parliament.
"They just can't beat me," said Aoun, who says he is a candidate for presidential elections only weeks away
However, Aoun's opponents said the strong showing by Gemayel had damaged the opposition leader's claim to be the strongest Christian political leader.
"It is a victory," said Samir Geagea, an ally of Gemayel.
Walid Jumblatt, the Druze leader, told the LBC TV channel that regardless of the final result, Gemayel had already won by vastly improving the showing of the majority coalition in the Christian heartland compared to a 2005 vote.
Before the final results became clear, both sides in Metn had accused the other side of fraud.
Each had supporters celebrating in convoys on the streets in Beirut and the Metn region.
Witnesses and security officials said Aoun and Gemayel supporters faced off in an area east of Beirut late on Sunday, with scores of Lebanese army troops and riot police deployed to prevent trouble.
Antoine Nasrallah, a spokesman for Aoun, also told Al Jazeera that one of their supporters was wounded in the hand when he was shot at by Gemayel supporters near the town of Bikfaya.
Gemayel called for calm on the streets. "We don't want anyone to drag us into a confrontation that we don't need," he said.
Lebanon's government and opposition have been locked in a fierce power struggle for months, and the choice of a new president is important to both sides.