Congress nominee K Venkatesh defeated K Mahadev of the Janata Dal-Secular by over 2,000 votes in the May 28 poll whose votes were counted today.
Periyapatna, about 200 km from the state capital Bangalore, did not vote with the rest of the state May 5 following the death of the BJP candidate.
Mr Venkatesh won 62,045 votes while Mahadev bagged 59,957, election officials told reporters.
The third place was taken by HD Ganesh of a regional outfit formed by former BJP minister B Sriramulu. He got over 5,000 votes.
The BJP, which was routed in the May 5 poll, fared miserably in Periyapatna as well with its candidate RT Satish coming fourth, getting only 3,731 votes and losing his security deposit.
More than 80 percent of Periyapatna's over 160,000 eligible voters had voted May 28.
With the Periyapatna victory, the Congress has taken eight of the 11 assembly seats from Mysore district.
It also boosted Chief Minister Siddaramaiah as Periyapatna falls in his home district Mysore.
The Congress victory has dashed the JD-S' hopes of becoming the second largest party in the assembly. It is now tied at the second spot with BJP as the two have won 40 seats each.
The remaining 22 seats are shared by smaller parties and individuals. One member is nominated to represent the Anglo-Indian community.