I found an answer on my own using two other QnAs on SO.
1) First you need to create a separate project containing the source of the library and compile it as jar.
If it's from Github you can just select File-> New-> Project from version control-> Git
and create a new project from the github source.
Then you need to compile it as jar or artifact in Intellij
Look at this question for that:
How to build jars from IntelliJ properly?
2) Then you need to open your project from which you want to import the jar or library and add it to the project and add it or register it as library.
Look here for that:
Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project
After doing these two steps I was successfully able to import the library.