Two cases of that, or something like it, have come up in my research.
In the 1850s, Missouri was a slave state in transition. It wasn't very enslaved, was exposed to free territory on the east and north, and most of its enslavers concentrated in the Missouri valley in the middle and west of the state. They grew mainly hemp for a cash crop. In the state's early days, it was a fairly solid slave state but since then St. Louis and environs had grown up considerably, flush with immigrants (lots of Germans, in particular) and midwesterners who were indifferent to adverse to slavery and saw the state developing more along the lines of Illinois or Indiana than Arkansas or Kentucky. The sentiment had its champion in Missouri's senior senator (senior in the sense that he had been Senator for as long as Missouri had senators, uninterrupted) Thomas Hart Benton. Benton, and most of his constituents, were by no means abolitionists. He didn't go around saying Missouri should end slavery, but he was opposed to proslavery militancy and eventually declared his personal dislike of the institution.
After the death of John C. Calhoun, the Senate's leading proslavery militant was probably David Rice Atchison. Atchison, from the 1840s, was Benton's junior colleague representing Missouri. They mostly got on well enough (Both were Democrats.) until the 1850s. Atchison came to see Benton as weak on slavery, which he certainly was. Atchison is representative of the increasingly aggressive proslavery consensus of the antebellum Democracy, whereas Benton hailed from and harkened back to an era that wasn't quite so insistent on it.
Both men command the loyalty of a faction in the Missouri Democracy and they go to town on each other. Atchison manages to organize a coalition of his Democracy and Missouri's Whigs for a simple bargain. It takes an outright majority of the state legislature to make a senator. The Whigs don't have that. The Democrats do, but only with Atchison's and Benton's wings united. Atchison's faction agree to support a Whig for the next term. They do the math and Benton becomes an ex-Senator in favor of Henry S. Geyer. Geyer had a fairly undistinguished senatorial career of one term. For two years he was Missouri's only Senator because the Bentonites were strong enough after Atchison made himself a bit infamous in Bleeding Kansas to deny him re-election too. Benton served a term in the House after his ouster, but then lost his seat for opposing the Kansas-Nebraska Act. Atchison spent a few years as a paramilitary leader for the proslavery side of the Kansas struggle, then inherited some property that took him away from the border and largely retired from politics.
This isn't quite a case of the Democratic majority straight-out electing a member of the opposing party, but it is the case of some Democrats doing that in coalition with the other party.
Benton was ousted from the Senate in 1851 and the House in 1854. At the same time as his Missouri travail played out, a much longer drama went on in Massachusetts. Massachusetts' elder statesman and rhetorical artisan Daniel Webster nailed his colors to the Compromise of 1850, including the much-hated Fugitive Slave Act of that year. Webster was a Whig, but he started out as a Federalist and he's old school enough to think parties shouldn't matter too much unless he personally commands one. His factionalism on that front helped compromise the presidency both times the Whigs won an election, though he's far from alone in that. Shortly after that, he gets appointed to Millard Fillmore's cabinet.
Webster takes the job and manages the appointment of Robert Winthrop to serve out the remainder of his term. Winthrop basically follows Webster's program as a pro-compromise man. He's a little squishy on the Fugitive Slave Act, but still sound in general. The thing is that lots of people in Massachusetts hate the Compromise of 1850, especially that law. Massachusetts at the time has three parties, the Whig majority, a Democratic minority, and the Free Soilers as a one-issue antislavery third party. The Democrats know they have no chance in Mass with a proslavery ticket. Even with an antislavery ticket, they lack the numbers to carry the state legislature in part because it's heavily gerrymandered in favor of Boston. The Free Soilers know that both the Democracy and Whigs have antislavery wings and antislavery is strong in Massachusetts. They're former Democrats (a few) and Whigs (mostly), after all. The Whig establishment isn't all Webster men (it's a bit to the left of them) but it's enough to the right of the Free Soilers on slavery that by 1850 they think it's probably not a viable vehicle for their politics unless heavily reformed.
The Free Soilers care a lot about fighting slavery. The Democrats range from "meh" to "yeah, that's cool but we really want to reform Massachusetts". Enough of the free soilers are ex-Democrats, Democracy-curious, or indifferent Whigs that the reform program isn't obnoxious to them as long as they get something out of a coalition. Henry Wilson masterminds one that largely amounts to an agreement on candidates in each district, so the two parties don't compete, and an implicit understanding that the Free Soilers will vote for the Democratic reform package and a Democratic governor in exchange for the Free Soilers getting a personal liberty law (to make it harder for enslavers to come in and take slaves who stole themselves to freedom) and the Senate seat. Almost from the start, the guy in mind for that seat is Charles Sumner.
Sumner is ideal in a lot of ways. His political career to date almost does not exist. He's given speeches and served as an advocate for various reform movements (antislavery, prisons, and peace mostly) and he was a Whig. He got on well with Whig luminaries in his early days and has moderately respectable Whig credentials up to the mid-1840s, but his increasingly uncompromising positions led to a degree of social ostracism from swanky Whig society and may have cost him a faculty post at Harvard. The lack of a career in office and his marginality in Massachusetts Whiggery meant he wasn't personally offensive to the Democrats, which other Free Soilers surely would have been. Nor was he a Democrat who would be odious to the mostly ex-Whig Free Soil party. It should be a done deal, right? The elections resulted in a Whig plurality in the legislature, but the Free Soil-Democracy coalition together had a majority.
Two problems soon emerge. Neither party is entirely comfortable with their coalition and they emphatically did not agree on a formal fusion. The business is held together by pinky swears. The Democrats come under pressure from the national party to fall in line and be good proslavery stooges, or at least as good as one can manage in Massachusetts. They get their governor and pretty soon he's getting friendly advice on those lines. Sumner, however, is still too radical an antislavery man for some of the Dems and they're willing to bolt the coalition for Anyone But Sumner. There are twenty or thirty of them, calling themselves Indomitables and led by Caleb Cushing. That's enough to spoil the election.
Meanwhile, many of the Free Soilers do not like Democrats one bit. They don't trust them not to bow to national pressure and have grudges in Massachusetts and National politics going back to Andrew Jackson against the party. There's a lot of tedious purity posturing in this, but they are right that the Democrats are more interested in their Massachusetts reform project than advancing Free Soil ends. How trustworthy can they actually be? Meanwhile, there are a lot of dissenting Whigs still in the regular party and most of the ex-Whigs believe, rightly, that Whiggery has long been the more antislavery of the two parties. They argue that the Free Soilers should junk the coalition in favor of either no senator and the expectation of a majority all their own at the next election, or to join up with those dissenting, non-Webster Whigs in favor of someone with better establishment credentials like Charles Francis Adams (off the John and John Quincy Adamses). CF Adams is in a bit of a spot here because he's personal friends with Sumner (though I guess Sumner liked Adams more than Adams liked Sumner...Adams was kind of a cold fish, at least according to Sumner's biographer) but he's also an antislavery man and a dissenting Whig.
What shakes out is that the Massachusetts Senate elects Sumner straightaway, kicking it over to the House. In the House we get the Indomitables and the Splitters. The election proceeds to drag on for months, with Sumner often having a plurality but never the majority he needs. Things eventually descend to shenanigans, with more votes being cast than there are House members. Whoops. Sumner gets news one night that he's been elected and well-wishers start showing up (at the Adams house, where Sumner regularly dines) but then they hear maybe he hasn't been elected at all. Young Henry Adams gets sent off to figure out what happened and comes back with news of the shenanigans.
The Massachusetts House had been using a standard ballot box to do the electing. Members just came up with a piece of paper that had a name on it and tucked the thing in. One or two had two names and there was a dispute over which one counted. It's not clear who is cheating, but obviously someone is regularly casting a few extra votes. The House adopts a Whig proposal that each member needs to vote by sealed envelope, so if anyone tries to slip in two they'll know right away. After twenty-six ballots, four months, and considerable acrimony, Sumner gets 193 of the 385 votes. That's one more than he needs. Henry Adams, who is pretty young at the time, was watching. He gets up and runs straight home with the news. The Whigs go home to mourn while the coalition party.