diff --git a/src/cluster/cluster.cpp b/src/cluster/cluster.cpp
index db3364350918bfe1e3c6f9144606151254e71986..06e27ab69fb08a81506685406c779f61ff6e9fd7 100644
--- a/src/cluster/cluster.cpp
+++ b/src/cluster/cluster.cpp
@@ -33,8 +33,12 @@
 #endif
 
 #ifdef USE_LAPACK
+#ifdef USE_MKL
+#include <mkl_lapacke.h>
+#else
+#include <lapacke.h>
+#endif
 #ifndef INCLUDE_LAPACK_CALLS_H_
-#include "lapacke.h"
 #include "../include/lapack_calls.h"
 #endif
 #endif
diff --git a/src/include/algebraic.h b/src/include/algebraic.h
index ae256a7d115870d61ae1924dcad6d2d26c760025..01437ac9d3f21d49610ae6921421e5933ebefc42 100644
--- a/src/include/algebraic.h
+++ b/src/include/algebraic.h
@@ -12,23 +12,29 @@
  * legacy serial function implementation is used as a fall-back.
  */
 
+#ifdef USE_LAPACK
+#ifdef USE_MKL
+#include <mkl_lapacke.h>
+#else
+#include <lapacke.h>
+#endif
+#else
+#define lapack_int int64_t
+#endif
+
 #ifndef INCLUDE_ALGEBRAIC_H_
 #define INCLUDE_ALGEBRAIC_H_
 
 #ifndef np_int
-#ifndef lapack_int
-#define np_int int64_t
-#else
 #define np_int lapack_int
 #endif
-#endif
 
 /*! \brief Perform in-place matrix inversion.
  *
  * \param mat: `complex double **` The matrix to be inverted (must be a square matrix).
- * \param size: `lapack_int` The size of the matrix (i.e. the number of its rows or columns).
+ * \param size: `np_int` The size of the matrix (i.e. the number of its rows or columns).
  * \param ier: `int &` Reference to an integer variable for returning a result flag.
- * \param max_size: `lapack_int` The maximum expected size (required by some call-backs,
+ * \param max_size: `np_int` The maximum expected size (required by some call-backs,
  * optional, defaults to 0).
  */
 void invert_matrix(dcomplex **mat, np_int size, int &ier, np_int max_size=0);
diff --git a/src/libnptm/algebraic.cpp b/src/libnptm/algebraic.cpp
index 9a4b5f4b9ac8d251d3a6d299e1c87072108a8f02..9456eaee80e119b1cb6f5f50d40396afa7461a15 100644
--- a/src/libnptm/algebraic.cpp
+++ b/src/libnptm/algebraic.cpp
@@ -9,10 +9,16 @@
 
 typedef __complex__ double dcomplex;
 
+#ifdef USE_LAPACK
+#ifdef USE_MKL
+#include <mkl_lapacke.h>
+#else
+#include <lapacke.h>
+#endif
 #ifndef INCLUDE_LAPACK_CALLS_H_
-#include "lapacke.h"
 #include "../include/lapack_calls.h"
 #endif
+#endif
 
 #ifndef INCLUDE_ALGEBRAIC_H_
 #include "../include/algebraic.h"
diff --git a/src/libnptm/lapack_calls.cpp b/src/libnptm/lapack_calls.cpp
index e8c84de083d449620405c9f452285b9e5cddd328..333871e0ae08702f4fcddfef68500ed454a77947 100644
--- a/src/libnptm/lapack_calls.cpp
+++ b/src/libnptm/lapack_calls.cpp
@@ -4,16 +4,27 @@
 
 typedef __complex__ double dcomplex;
 
+#ifdef USE_LAPACK
+#ifdef USE_MKL
+#include <mkl_lapacke.h>
+#else
+#include <lapacke.h>
+#endif
+
 #ifndef INCLUDE_LAPACK_CALLS_H_
-#include "lapacke.h"
 #include "../include/lapack_calls.h"
 #endif
+#endif
 
 #ifdef USE_LAPACK
 void zinvert(dcomplex **mat, lapack_int n, int &jer) {
   jer = 0;
-  __complex__ double *arr = new dcomplex[n * n];
+  dcomplex *arr = new dcomplex[n * n];
   const dcomplex uim = 0.0 + 1.0 * I;
+
+#ifdef USE_MKL
+  MKL_Complex16 *arr2 = (MKL_Complex16 *) arr;
+#endif
   for (lapack_int i = 0; i < n; i++) {
     for (lapack_int j = 0; j < n; j++) {
       lapack_int idx = i + n * j;
@@ -23,8 +34,14 @@ void zinvert(dcomplex **mat, lapack_int n, int &jer) {
   
   lapack_int* IPIV = new lapack_int[n]();
   
-  if (!LAPACKE_zgetrf(LAPACK_ROW_MAJOR, n, n, arr, n, IPIV)) jer = 1;
-  if (!LAPACKE_zgetri(LAPACK_ROW_MAJOR, n, arr, n, IPIV)) jer = 2;
+#ifdef USE_MKL
+  LAPACKE_zgetrf(LAPACK_ROW_MAJOR, n, n, arr2, n, IPIV);
+  LAPACKE_zgetri(LAPACK_ROW_MAJOR, n, arr2, n, IPIV);
+#else
+  LAPACKE_zgetrf(LAPACK_ROW_MAJOR, n, n, arr, n, IPIV);
+  LAPACKE_zgetri(LAPACK_ROW_MAJOR, n, arr, n, IPIV);
+#endif
+
   for (lapack_int i = 0; i < n; i++) {
     for (lapack_int j = 0; j < n; j++) {
       lapack_int idx = i + n * j;
diff --git a/src/make.inc b/src/make.inc
index 712b27f398f0d680638d07fe62c12ba24dab4c6d..2ba3d6b135da8c1627da9b0e5504c6c266cc8777 100644
--- a/src/make.inc
+++ b/src/make.inc
@@ -77,7 +77,7 @@ override CXXFLAGS=-O3 -ggdb -pg -coverage -I$(HDF5_INCLUDE)
 ifdef USE_LAPACK
 override CXXFLAGS+= -DUSE_LAPACK -DLAPACK_ILP64 
 ifdef USE_MKL
-override CXXFLAGS+= -DMKL_ILP64 -I$(MKLROOT)/include
+override CXXFLAGS+= -DMKL_ILP64 -DUSE_MKL -I$(MKLROOT)/include
 endif
 endif
 endif