Turkish stocks plummeted on Wednesday as the country's struggles to defend its currency ahead of a key election on Sunday sent a key interest rate to an all-time high.

Turkey's benchmark stock index, the ISE National 100 index, dropped 5.2 percent and was on track for its worst day since July 18, when it fell 7.1 percent. The iShares MSCI Turkey ETF (TUR), which tracks Turkish equities in the U.S., fell 7.7 percent.

The slide in Turkey's equity market came as the government directed the country's banks to withhold lira liquidity from the offshore swap market in an attempt to keep the lira from falling sharply. This sent the overnight Turkish swap rate to 1,200 percent, by far the highest ever, according to Reuters.

Turkey's move effectively kept foreign investors from betting against Turkish assets ahead of local elections that are largely seen as a referendum on President Recep Tayyip Erdogan. As of 12:19 p.m. in New York, the lira traded 1.8 percent lower against the dollar at 5.42.

Support for Erdogan's party, the AK Party, has deteriorated this year as Turkey struggles curb its economic downfall. Turkey's economy contracted by 3 percent in the fourth quarter of last year after three straight quarters of declining growth. The unemployment rate in Turkey also skyrocketed to 13.5 percent in December from 9.7 percent in April.

This has all contributed to the lira plummeting more than 36 percent against the dollar in the past year. Turkey tried to defend its currency through rate hikes, bringing its overnight lending rate to 24 percent from 8 percent in 2018.

"We do think the economy will begin to recover over the coming months. Inflation is falling, which should ease the squeeze on consumers," William Jackson, chief emerging markets economist at Capital Economics, wrote in a note. However, "local assets remain particularly vulnerable to bouts of risk aversion. There are two main reasons for this. One is concerns about the direction of policymaking. The other is that Turkey still has a large external financing requirement – it requires large capital inflows to roll over maturing external debts."

"We expect risk aversion to rise over this year as a result of weak global growth," Jackson said.

—CNBC's Michael Bloom and Reuters contributed to this report.

Subscribe to CNBC on YouTube.