We report for the first time the Al and C codoping effect on the structures and superconductivity in MgB2. It was found that both the lattice parameters and the Tc decreased monotonically with increasing doping level of both Al and C. The Tc dropped to 27.5 and 7 K for x=0.2 and for x=0.4, respectively. The reduction of Tc for the codoping was found to be quicker than for individual Al doping and slower than for individual C doping at the same doping levels. First-principles calculations indicated that the observed decrease in Tc for the codoped MgB2 can be understood in terms of a band filling effect due to the electron doping by both Al and C. However, it is suggested that other factors may also play a role in the Tc reduction in the real Mg1-xAlxB2-xCx samples. Furthermore, the Al and C codoping also reduces Jc and weakens flux pinning in MgB2.