What you describe fits yakkha (Pali) or yaksha (Sanskrit). You can find more info on this on the Wikipedia page on Yaksha where it says:
Yaksha (Sanskrit: यक्ष yakṣa, Kannada: ಯಕ್ಷ yakṣa, Tamil: யகன் yakan,
இயக்கன் iyakan, Odia: ଯକ୍ଷ jôkhyô, Pali: yakkha) are a broad class
of nature-spirits, usually benevolent, but sometimes mischievous or
capricious, connected with water, fertility, trees, the forest,
treasure and wilderness. They appear in Hindu, Jain and Buddhist
texts, as well as ancient and medieval era temples of South Asia and
Southeast Asia as guardian deities. The feminine form of the word is
yakṣī or Yakshini (yakṣiṇī).
In Hindu, Jain, and Buddhist texts, the yakṣa has a dual personality.
On the one hand, a yakṣa may be an inoffensive nature-fairy,
associated with woods and mountains; but there is also a darker
version of the yakṣa, which is a kind of ghost (bhuta) that haunts the
wilderness and waylays and devours travelers, similar to the rakṣasas.
The story in Udana 4.4 describes an act of mischief committed by a yakkha:
A third time, the first yakkha said to the second, "I'm inspired to
give this contemplative a blow on the head."
A third time, the second yakkha said to the first, "Enough of that, my
good friend. Don't lay a hand on the contemplative. He's an
outstanding contemplative, of great power & great might."
Then the first yakkha, ignoring the second yakkha, gave Ven. Sāriputta
a blow on the head. And with that blow he might have knocked over an
elephant seven or eight cubits tall, or split a great rocky crag. But
right there the yakkha — yelling, "I'm burning!" — fell into the Great
Hell.
Now, Ven. Moggallāna — with his divine eye, pure and surpassing the
human — saw the yakkha give Ven. Sāriputta a blow on the head. Seeing
this, he went to Ven. Sāriputta and, on arrival, said to him, "I hope
you are well, friend Sāriputta. I hope you are comfortable. I hope you
are feeling no pain."
"I am well, friend Moggallāna. I am comfortable. But I do have a
slight headache."
However, in SN 10.8, a yakkha tried to be helpful to the Buddha's lay disciple Anathapindika:
I have heard that on one occasion the Blessed One was staying near
Rajagaha in the Cool Grove. Now at that time Anathapindika the
householder had arrived in Rajagaha on some business. He heard, "An
Awakened One, they say, has appeared in the world," and he wanted to
go right then to see the Blessed One. Then the thought occurred to
him, "Today is not the proper time to go to see the Blessed One.
Tomorrow I will go to see the Blessed One at the proper time." With
his mindfulness immersed in the Awakened One he lay down to sleep.
Three times he got up during the night, thinking it was light. Then he
went to the gate to the charnel ground. Non-human beings opened the
gate.
When Anathapindika the householder had left the city, the light
vanished and darkness appeared. Fear, terror, & horripilation arose,
and because of that he wanted to turn back. Then Sivaka the
yakkha-spirit, invisible, proclaimed:
A hundred elephants,
a hundred horses,
a hundred mule-drawn carts,
a hundred-thousand maidens
adorned with jewels & earrings
aren't worth one-sixteenth
of one step forward.
Go forward, householder!
Go forward, householder!
Going forward is better for you,
not back!
The darkness then vanished for Anathapindika and the light appeared.
The fear, terror, & horripilation he had felt subsided.