There is a slightly different version of the story of Vritra as mentioned in the Mahabharata. There Indra is defeated by Vritra, gets advice from Vishnu, befriends Vritra based on that advice, and later kills Vritra by throwing foam infused with Vishnu's power on him.
(All of the following are from K.M. Ganguly's translation of Vyasa's MahaBharata)
MahaBharata Udyoga Parva, Section 9: Indra is defeated by Vritra: Long story but Twashta creates Vritra since Indra kills his son. Vritra trounces Indra.
MahaBharata Udyoga Parva, Section 10: Indra asks Vishnu for help and hatches a plan:
"Indra said, This whole indestructible universe, O gods, hath been pervaded by Vritra. There is nothing that can be equal to the task of opposing him. I was capable of yore, but now I am incapable. What good betide you, can I do? I believe him to be unapproachable. Powerful and magnanimous, possessing immeasurable strength in fight, he would be able to swallow up all the three worlds with the gods, the Asuras, and the men. Therefore, hear ye dwellers of heaven, this is my resolution. Proceeding to the abode of Vishnu, in company with that high-souled Being must we consult, and ascertain the means of slaying this ruthless wretch.' "Salya continued, 'Indra having thus spoken, the gods with that host of Rishis repaired to the mighty god Vishnu to place themselves under the-protection of that protector of all. And afflicted with the dread of Vritra, they said unto the Supreme Lord of the deities. Thou hadst in former times covered the three worlds with three steps. Thou hadst procured the ambrosial food, O Vishnu, and destroyed the Asuras in battle. Thou didst bind the great Asura Vali and hadst raised Indra to the throne of heaven. Thou art the lord of the gods, and this entire universe is pervaded by thee. Thou art the God, the mighty Deity, saluted by all persons. Be thou the refuge of all the celestials together with Indra, O best of gods. The whole universe, O slayer of Asuras, hath been pervaded by Vritra. And Vishnu said, 'I am no doubt bound to do what is for your good. I shall, therefore, tell you of a contrivance whereby he may be annihilated. Do ye with the Rishis and the Gandharvas repair to the place where Vritra that bearer of a universal form is and adopt towards him a conciliatory policy. You will thus succeed in overthrowing him. By virtue of my power, victory, ye gods, will be won by Indra, for, remaining invisible, I shall enter into his thunderbolt, that best of weapons. O foremost of gods, depart ye with the Rishis and the Gandharvas. Let there be no delay in effecting a peace between Indra and Vritra.'
MahaBharata Udyoga Parva, Section 10: Indra slays Vritra with Vishnu's
Thus peace having been concluded, Vritra was very much pleased. And Indra also became pleased though constantly occupied with the thought of killing Vritra. And the chief of the deities passed his time in search of a loophole, uneasy (in mind). And on a certain day when it was evening and the hour awful, Indra caught sight of the mighty Asura on the coast of the sea. And he bethought himself of the boon that was granted to the illustrious Asura, saying, 'This is the awful evening time; it is neither day, nor night; and this Vritra, my enemy, who hath stripped me of my all, must undoubtedly be killed by me. If I do not kill Vritra, this great and mighty Asura of gigantic frame, even by deceit, it will not go well with me.' And as Indra thought of all this, bearing Vishnu in mind he beheld at that instant in the sea a mass of froth as large as a hill. And he said, 'This is neither dry, nor wet, nor is it a weapon; let me hurl it at Vritra. Without doubt, he will die immediately.' And he threw at Vritra that mass of froth blended with the thunderbolt. And Vishnu, having entered within that froth, put an end to the life of Vritra. And when Vritra was killed, the cardinal points were free from gloom; and there also blew a pleasant breeze; and all beings were much pleased.
This leads to Indra getting ashamed and fleeing from the scene and later Nahusha becoming the new Indra and getting cursed by Agastya etc.