"Middle" is a pretty broad term when it comes to a food chain. Here on earth it would describe anything between modern humans and plankton. So most likely the answer is yes... But that's not fun, so let's look a little deeper.
Most species that are commonly recognized as intelligent are social, most are carnivorous or omnivorous and most are mammals. Notice that I said "most" quite a few times there. There are a few notable exceptions like the cephalopods, which aren't mammals or particularly sociable.
Brains are hungry things which require a lot of calories, in most environments that means eating your fellow creatures, at least occasionally.
Bigger brains usually need time to grow, develop, and train which means that mammals get a bit of an advantage due to lactation and hence attention/protection from a parent.
Which brings us to the social component. Animals the have bigger brains often have longer adolescent periods, which means that they aren't fully self sufficient, thus they need protection, food, and so on. Animals that can rear young cooperatively get a significant advantage because they can leave the crumb-snatchers with the neighbors while they hunt and forage.
It's not uncommon to see "higher level" predators gain some higher intelligence. See dolphins, wolves (pack hunters in general)
It's also not uncommon to see "lower level" omnivores gain some higher intelligence. See raccoons, monkeys
As for the notable exceptions... We're still not sure why cephalopods have evolved to be as apparently intelligent as they are. Some seem to think it may be due to sexual selection, female cuttlefish seem more likely to select males that are smart enough to disguise themselves to sneak by the larger stronger males.
So... If you're working on intelligence in an alien world, just make it sexy and things should progress pretty well...