The prime minister was addressing a public meeting here after launching projects worth Rs 2,980 crore.
"Rivals are coming together just to oppose us. Political rivals who did not even like to look at each other are now coming together just to oppose us," he said, without naming the two parties.
The prime minister mocked their bid to stitch an anti-BJP alliance, while recalling the 1995 state guest house incident in Lucknow in which Bahujan Samaj Party chief Mayawati was targeted by Samajwadi Party workers.
Modi's attack came amid reports of the two parties agreeing to form an alliance to take on the Bharatiya Janata Party in the upcoming Lok Sabha elections.
The prime minister said they are coming together because they are afraid of the country's watchman.
"They fear the chowkidar, which is why they want to throw me out of power," Modi said, citing alleged scams in sand and gravel mining in Uttar Pradesh when the SP and the BSP were separately in power.
Referring to the recent CBI raids in the state in connection with the alleged mining scams in that period, Modi said, "The investigating agencies are seeking an answer from them about their misdeeds and so they are conspiring against the chowkidar."
"Some people are coming together against the chowkidar. In Uttar Pradesh, you can also see that those who deprived the poor of their rights by snatching sand and gravel have now started a cooperation campaign in corruption," he said.
"To hide their scams and corruption, they are shaking hands, he said.
Those who were not ready to see eye to eye with each other are shaking hands for petty political gains and ready to forget the shameful guest house case and other incidents," Modi said.
In a possible reference to Congress leader Rahul Gandhi's remark at a rally in Jaipur earlier in the day, the prime minister said the opposition leaders are bent upon insulting a woman defence minister.
Gandhi had said Modi got a woman to defend him in Parliament because he couldn't do so himself.
This is not an insult to a woman, but an insult to entire India's women power, for which these irresponsible leaders will have to pay the price," Modi said.
The prime minister said it was a matter of pride that a woman has become defence minister for the first time in the country.
He also referred to AgustaWestland middleman Christian Michel, saying 'Michel mama' is in the country's custody and they are worried that he might reveal secrets.
Describing himself as a "chowkidar", Modi said he has undertaken a "safai" (clean-up) mission to rid the country of corruption and he cannot be "bought" "scared off".
"This chowkidar doesn't sleep and can spot a wrongdoer even in darkness. They may continue abusing me but I will not stop my mission to uproot corruption," Modi said.
Defending introduction of 10 per cent reservation for the general category poor in government jobs and educational institutions, Modi said the Constitution (Amendment) Bill is a strong answer to those "spreading lies".
Modi said the rights of the deprived sections, including the Dalits and the tribals won't be affected because of this bill, which he described as a "historic step" aimed at welfare of the deprived sections of society.
Hitting back at the Opposition for terming the quota bill an election gimmick, Modi asked if there ever has been a span of six months without the country going through an election.
"After coming to power, we undertook developmental work and projects in areas which were ignored only because they (Congress) indulged in vote bank politics," he said.
Speaking on Ayushman Bharat, he said around seven lakh poor people were treated in various hospitals under the Yojana within only 100 days of its launch.
"The GST has gone down by 18 per cent for necessary items. The GST was implemented to make the taxation process easy for dealers and businessmen," he said.
Modi earlier launched civic projects worth Rs 3,907 crore during his visit to the Taj city, including the Gangajal project to provide consistent water supply.
This was Modi's second visit to the city as prime minister.
During his earlier visit in November 2016, he had launched a housing project, the PM Awas Yojana (Gramin), under which 65 lakh houses have been built so far in the country, including 9.2 lakh in Uttar Pradesh, said officials.
"Hope the PM will return from Taj Mahal after learning a lesson of affection and love from it," he tweeted hours before the prime minister's visit.
Yadav also said he hoped Modi would remember the pain of farmers growing potato, sugarcane and wheat in nearby areas.
(This story has not been edited by Business Standard staff and is auto-generated from a syndicated feed.)