Mr Upadhayay's victory assumes significance, as it was from here that Chief Minister Yogi Adityanath launched his hectic campaign for the civic body elections.
"Yogi ji gets the total credit for this victory. He has been giving a lot of gifts to Ayodhya in the last few months and has been very involved here. He has opened his treasury for Ayodhya, you will see the results in 1 year," he told NDTV.
The election for the Ayodhya mayor's post seat witnessed a close fight between Mr Upadhyay and Gulshan Bindu of the Samajwadi Party. The BJP leader received 44,642 votes (44.9 per cent), while Mr Bindu was close with 41,041 votes.
BSP's Girish Chandra polled 6,033 votes, while Shailendra Mani of the Congress got 3,601 votes. AAP's candidate Sarvesh Kumar Verma got 1,180 votes.
The Adityanath government had decided to constitute municipal corporations for Ayodhya and Mathura-Vrindavan during its initial days in power.
"My priority will be to increase greenery in Ayodhya, make it clean and hygienic and ensure its all-round development. Every word mentioned in the Sankalp Patra (manifesto) will be implemented in letter and spirit," Mr Upadhyay, who turns 41 on December 14, said.
The BJP won big in mayoral elections in 14 of 16 municipal corporations in Uttar Pradesh. The state's ruling party is also leading in municipal councils and nagar panchayats. "The BJP's historic win in the UP civic polls is because of PM Modi's development policies and Amit Shah's guidance," Mr Adityanath said.
(with inputs from agencies)