Sayyidah Aishah (may Allah be pleased with her) says that the Messenger of Allah (peace and blessings be upon him) was in pain, and he (peace and blessings be upon him) ordered Sayyiduna Abu Bakr (may Allah be pleased with him) to "lead the people in prayer". Then the Prophet (peace and blessings be upon him) felt some ease, so he (peace and blessings be upon him) came and sat beside Sayyiduna Abu Bakr (may Allah be pleased with him). The Prophet (peace and blessings be upon him), sitting, was leading Sayyiduna Abu Bakr (may Allah be pleased with him) as imam, and Sayyiduna Abu Bakr (may Allah be pleased with him) was leading the people as imam.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 5081