1. In medium saucepan combine garlic and 6 cups water; season liberally with salt. Bring to boil over medium heat, add lentils and simmer until lentils are just tender, 25 to 30 minutes. Drain and mash garlic into lentils and transfer to mixing bowl.
2. In medium saucepan combine rice, 2 cups water and a large pinch salt. Bring to boil over medium-high heat, cover and reduce to low. Cook 1 hour, until the rice is very soft, then transfer to bowl with lentils and toss to combine. Season to taste with salt and pepper.
3. While rice cooks, melt butter in large skillet or saucepan over medium-high heat. Add onions and cook, stirring frequently, until very well browned and dramatically reduced in volume, about 12 to 20 minutes. (Add a splash or two of water if necessary to prevent sticking or burning.) Season with salt and pepper.
4. Adjust oven rack to middle position and preheat to 400 degrees. Spread lentil and rice mixture into buttered 9-by-13-inch baking or casserole dish and cover with an even layer of onion mixture. Wrap tightly with foil and bake for 30 minutes. Allow to cool for 5 minutes, then serve accompanied by yogurt, harissa (see accompanying recipe) or hot sauce, and salt.